Skip to content

Commit 9c98f76

Browse files
Merge pull request #8017 from patrickdillon/tweak-capg-failuredomains
CORS-3213: Tweak GCPCluster Failure Domain Logic
2 parents d29889d + d6a32f1 commit 9c98f76

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

pkg/asset/manifests/gcp/cluster.go

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -140,32 +140,35 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
140140
// only use zones if both the compute and control plane node availability zones exist.
141141
func findFailureDomains(installConfig *installconfig.InstallConfig) []string {
142142
zones := sets.New[string]()
143-
defaultMachinePlatformDefined := false
144-
if gcpPlatform := installConfig.Config.Platform.GCP; gcpPlatform != nil && gcpPlatform.DefaultMachinePlatform != nil {
145-
defaultMachinePlatformDefined = true
146-
for _, zone := range gcpPlatform.DefaultMachinePlatform.Zones {
143+
144+
var controlPlaneZones, computeZones []string
145+
if installConfig.Config.ControlPlane.Platform.GCP != nil {
146+
controlPlaneZones = installConfig.Config.ControlPlane.Platform.GCP.Zones
147+
}
148+
149+
if installConfig.Config.Compute[0].Platform.GCP != nil {
150+
computeZones = installConfig.Config.Compute[0].Platform.GCP.Zones
151+
}
152+
153+
def := installConfig.Config.GCP.DefaultMachinePlatform
154+
if def != nil && len(def.Zones) > 0 {
155+
for _, zone := range def.Zones {
156+
zones.Insert(zone)
157+
}
158+
159+
for _, zone := range controlPlaneZones {
147160
zones.Insert(zone)
148161
}
149162

150-
if installConfig.Config.ControlPlane.Platform.GCP != nil {
151-
for _, zone := range installConfig.Config.ControlPlane.Platform.GCP.Zones {
152-
zones.Insert(zone)
153-
}
163+
for _, zone := range computeZones {
164+
zones.Insert(zone)
154165
}
155-
if installConfig.Config.Compute[0].Platform.GCP != nil {
156-
for _, zone := range installConfig.Config.Compute[0].Platform.GCP.Zones {
157-
zones.Insert(zone)
158-
}
166+
} else if len(controlPlaneZones) > 0 && len(computeZones) > 0 {
167+
for _, zone := range controlPlaneZones {
168+
zones.Insert(zone)
159169
}
160-
}
161-
if !defaultMachinePlatformDefined {
162-
if installConfig.Config.ControlPlane.Platform.GCP != nil && installConfig.Config.Compute[0].Platform.GCP != nil {
163-
for _, zone := range installConfig.Config.ControlPlane.Platform.GCP.Zones {
164-
zones.Insert(zone)
165-
}
166-
for _, zone := range installConfig.Config.Compute[0].Platform.GCP.Zones {
167-
zones.Insert(zone)
168-
}
170+
for _, zone := range computeZones {
171+
zones.Insert(zone)
169172
}
170173
}
171174

0 commit comments

Comments
 (0)