Skip to content

Commit d6a32f1

Browse files
committed
GCP Cluster Manifest: Set Failure Domains
Updates the failure domain logic for the GCP Cluster manifest so that failure domains are populated only when zones are populated on both machine pools. Prior to this change, we only checked if the machine pools were defined, not that the zones were included.
1 parent eb922c0 commit d6a32f1

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
@@ -137,32 +137,35 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
137137
// only use zones if both the compute and control plane node availability zones exist.
138138
func findFailureDomains(installConfig *installconfig.InstallConfig) []string {
139139
zones := sets.New[string]()
140-
defaultMachinePlatformDefined := false
141-
if gcpPlatform := installConfig.Config.Platform.GCP; gcpPlatform != nil && gcpPlatform.DefaultMachinePlatform != nil {
142-
defaultMachinePlatformDefined = true
143-
for _, zone := range gcpPlatform.DefaultMachinePlatform.Zones {
140+
141+
var controlPlaneZones, computeZones []string
142+
if installConfig.Config.ControlPlane.Platform.GCP != nil {
143+
controlPlaneZones = installConfig.Config.ControlPlane.Platform.GCP.Zones
144+
}
145+
146+
if installConfig.Config.Compute[0].Platform.GCP != nil {
147+
computeZones = installConfig.Config.Compute[0].Platform.GCP.Zones
148+
}
149+
150+
def := installConfig.Config.GCP.DefaultMachinePlatform
151+
if def != nil && len(def.Zones) > 0 {
152+
for _, zone := range def.Zones {
153+
zones.Insert(zone)
154+
}
155+
156+
for _, zone := range controlPlaneZones {
144157
zones.Insert(zone)
145158
}
146159

147-
if installConfig.Config.ControlPlane.Platform.GCP != nil {
148-
for _, zone := range installConfig.Config.ControlPlane.Platform.GCP.Zones {
149-
zones.Insert(zone)
150-
}
160+
for _, zone := range computeZones {
161+
zones.Insert(zone)
151162
}
152-
if installConfig.Config.Compute[0].Platform.GCP != nil {
153-
for _, zone := range installConfig.Config.Compute[0].Platform.GCP.Zones {
154-
zones.Insert(zone)
155-
}
163+
} else if len(controlPlaneZones) > 0 && len(computeZones) > 0 {
164+
for _, zone := range controlPlaneZones {
165+
zones.Insert(zone)
156166
}
157-
}
158-
if !defaultMachinePlatformDefined {
159-
if installConfig.Config.ControlPlane.Platform.GCP != nil && installConfig.Config.Compute[0].Platform.GCP != nil {
160-
for _, zone := range installConfig.Config.ControlPlane.Platform.GCP.Zones {
161-
zones.Insert(zone)
162-
}
163-
for _, zone := range installConfig.Config.Compute[0].Platform.GCP.Zones {
164-
zones.Insert(zone)
165-
}
167+
for _, zone := range computeZones {
168+
zones.Insert(zone)
166169
}
167170
}
168171

0 commit comments

Comments
 (0)