Skip to content

Commit a71a77e

Browse files
author
Matt Pryor
committed
Allow for omiting AZ from control plane nodes
1 parent 6859acb commit a71a77e

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

api/v1alpha6/openstackcluster_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ type OpenStackClusterSpec struct {
126126
// ControlPlaneAvailabilityZones is the az to deploy control plane to
127127
ControlPlaneAvailabilityZones []string `json:"controlPlaneAvailabilityZones,omitempty"`
128128

129+
// Indicates whether to omit the az for control plane nodes, allowing the Nova scheduler
130+
// to make a decision on which az to use based on other scheduling constraints
131+
ControlPlaneOmitAvailabilityZone bool `json:"controlPlaneOmitAvailabilityZone,omitempty"`
132+
129133
// Bastion is the OpenStack instance to login the nodes
130134
//
131135
// As a rolling update is not ideal during a bastion host session, we

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4724,6 +4724,11 @@ spec:
47244724
- host
47254725
- port
47264726
type: object
4727+
controlPlaneOmitAvailabilityZone:
4728+
description: Indicates whether to omit the az for control plane nodes,
4729+
allowing the Nova scheduler to make a decision on which az to use
4730+
based on other scheduling constraints
4731+
type: boolean
47274732
disableAPIServerFloatingIP:
47284733
description: DisableAPIServerFloatingIP determines whether or not
47294734
to attempt to attach a floating IP to the API server. This allows

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,11 @@ spec:
19621962
- host
19631963
- port
19641964
type: object
1965+
controlPlaneOmitAvailabilityZone:
1966+
description: Indicates whether to omit the az for control
1967+
plane nodes, allowing the Nova scheduler to make a decision
1968+
on which az to use based on other scheduling constraints
1969+
type: boolean
19651970
disableAPIServerFloatingIP:
19661971
description: DisableAPIServerFloatingIP determines whether
19671972
or not to attempt to attach a floating IP to the API server.

controllers/openstackcluster_controller.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,16 @@ func reconcileNormal(ctx context.Context, scope *scope.Scope, patchHelper *patch
280280
return ctrl.Result{}, err
281281
}
282282

283-
// Create a new list to remove any Availability
284-
// Zones that have been removed from OpenStack
283+
// Create a new list in case any AZs have been removed from OpenStack
285284
openStackCluster.Status.FailureDomains = make(clusterv1.FailureDomains)
286285
for _, az := range availabilityZones {
287-
found := true
288-
// If Az given, then check whether it's in the allow list
289-
// If no Az given, then by default put into allow list
286+
// By default, the AZ is used or not used for control plane nodes depending on the flag
287+
found := !openStackCluster.Spec.ControlPlaneOmitAvailabilityZone
288+
// If explicit AZs for control plane nodes are given, they override the value
290289
if len(openStackCluster.Spec.ControlPlaneAvailabilityZones) > 0 {
291-
if contains(openStackCluster.Spec.ControlPlaneAvailabilityZones, az.ZoneName) {
292-
found = true
293-
} else {
294-
found = false
295-
}
290+
found = contains(openStackCluster.Spec.ControlPlaneAvailabilityZones, az.ZoneName)
296291
}
297-
292+
// Add the AZ object to the failure domains for the cluster
298293
openStackCluster.Status.FailureDomains[az.ZoneName] = clusterv1.FailureDomainSpec{
299294
ControlPlane: found,
300295
}

0 commit comments

Comments
 (0)