Skip to content

Commit 26885d1

Browse files
Merge pull request openshift#8681 from danwinship/bootstrap-node-ip
OCPBUGS-35406: Use service CIDRs to determine bootstrap kubelet IP family
2 parents 01b922e + 032c091 commit 26885d1

File tree

1 file changed

+10
-41
lines changed

1 file changed

+10
-41
lines changed

pkg/asset/ignition/bootstrap/common.go

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,15 @@ func (a *Common) getTemplateData(dependencies asset.Parents, bootstrapInPlace bo
300300
bootstrapNodeIP = ""
301301
}
302302

303-
platformFirstAPIVIP := firstAPIVIP(&installConfig.Config.Platform)
304-
APIIntVIPonIPv6 := utilsnet.IsIPv6String(platformFirstAPIVIP)
305-
306-
networkStack := 0
307-
for _, snet := range installConfig.Config.ServiceNetwork {
308-
if snet.IP.To4() != nil {
309-
networkStack |= 1
303+
var hasIPv4, hasIPv6, ipv6Primary bool
304+
for i, snet := range installConfig.Config.ServiceNetwork {
305+
if utilsnet.IsIPv4(snet.IP) {
306+
hasIPv4 = true
310307
} else {
311-
networkStack |= 2
308+
hasIPv6 = true
309+
if i == 0 {
310+
ipv6Primary = true
311+
}
312312
}
313313
}
314314

@@ -341,8 +341,8 @@ func (a *Common) getTemplateData(dependencies asset.Parents, bootstrapInPlace bo
341341
PlatformData: platformData,
342342
ClusterProfile: clusterProfile,
343343
BootstrapInPlace: bootstrapInPlaceConfig,
344-
UseIPv6ForNodeIP: APIIntVIPonIPv6,
345-
UseDualForNodeIP: networkStack == 3,
344+
UseIPv6ForNodeIP: ipv6Primary,
345+
UseDualForNodeIP: hasIPv4 && hasIPv6,
346346
IsFCOS: installConfig.Config.IsFCOS(),
347347
IsSCOS: installConfig.Config.IsSCOS(),
348348
IsOKD: installConfig.Config.IsOKD(),
@@ -703,34 +703,3 @@ func warnIfCertificatesExpired(config *igntypes.Config) {
703703
logrus.Warnf("Bootstrap Ignition-Config: %d certificates expired. Installation attempts with the created Ignition-Configs will possibly fail.", expiredCerts)
704704
}
705705
}
706-
707-
// APIVIPs returns the string representations of the platform's API VIPs
708-
// It returns nil if the platform does not configure VIPs
709-
func apiVIPs(p *types.Platform) []string {
710-
switch {
711-
case p == nil:
712-
return nil
713-
case p.BareMetal != nil:
714-
return p.BareMetal.APIVIPs
715-
case p.OpenStack != nil:
716-
return p.OpenStack.APIVIPs
717-
case p.VSphere != nil:
718-
return p.VSphere.APIVIPs
719-
case p.Ovirt != nil:
720-
return p.Ovirt.APIVIPs
721-
case p.Nutanix != nil:
722-
return p.Nutanix.APIVIPs
723-
default:
724-
return nil
725-
}
726-
}
727-
728-
// firstAPIVIP returns the first VIP of the API server (e.g. in case of
729-
// dual-stack)
730-
func firstAPIVIP(p *types.Platform) string {
731-
for _, vip := range apiVIPs(p) {
732-
return vip
733-
}
734-
735-
return ""
736-
}

0 commit comments

Comments
 (0)