Skip to content

Commit d207436

Browse files
author
Matt Pryor
committed
Allow for omiting AZ from control plane nodes
1 parent 68a9ee6 commit d207436

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
@@ -129,6 +129,10 @@ type OpenStackClusterSpec struct {
129129
// +listType=set
130130
ControlPlaneAvailabilityZones []string `json:"controlPlaneAvailabilityZones,omitempty"`
131131

132+
// Indicates whether to omit the az for control plane nodes, allowing the Nova scheduler
133+
// to make a decision on which az to use based on other scheduling constraints
134+
ControlPlaneOmitAvailabilityZone bool `json:"controlPlaneOmitAvailabilityZone,omitempty"`
135+
132136
// Bastion is the OpenStack instance to login the nodes
133137
//
134138
// 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
@@ -4728,6 +4728,11 @@ spec:
47284728
- host
47294729
- port
47304730
type: object
4731+
controlPlaneOmitAvailabilityZone:
4732+
description: Indicates whether to omit the az for control plane nodes,
4733+
allowing the Nova scheduler to make a decision on which az to use
4734+
based on other scheduling constraints
4735+
type: boolean
47314736
disableAPIServerFloatingIP:
47324737
description: DisableAPIServerFloatingIP determines whether or not
47334738
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
@@ -1966,6 +1966,11 @@ spec:
19661966
- host
19671967
- port
19681968
type: object
1969+
controlPlaneOmitAvailabilityZone:
1970+
description: Indicates whether to omit the az for control
1971+
plane nodes, allowing the Nova scheduler to make a decision
1972+
on which az to use based on other scheduling constraints
1973+
type: boolean
19691974
disableAPIServerFloatingIP:
19701975
description: DisableAPIServerFloatingIP determines whether
19711976
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)