Skip to content

Commit acab3dc

Browse files
authored
Merge pull request #1318 from stackhpc/feature/control-plane-omit-az
✨ Allow for omitting AZ from control plane nodes
2 parents 5723804 + 5b138e7 commit acab3dc

10 files changed

+83
-25
lines changed

api/v1alpha3/conversion_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ func TestFuzzyConversion(t *testing.T) {
235235
v1alpha6Cluster.Spec.Bastion.Instance.ImageUUID = ""
236236
v1alpha6Cluster.Spec.Bastion.Instance.Ports = nil
237237
}
238+
v1alpha6Cluster.Spec.ControlPlaneOmitAvailabilityZone = false
238239

239240
v1alpha6Cluster.Status.FailureMessage = nil
240241
v1alpha6Cluster.Status.FailureReason = nil

api/v1alpha3/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha4/conversion_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ func TestFuzzyConversion(t *testing.T) {
331331

332332
v1alpha6Cluster.Spec.APIServerLoadBalancer.AllowedCIDRs = nil
333333

334+
v1alpha6Cluster.Spec.ControlPlaneOmitAvailabilityZone = false
335+
334336
if v1alpha6Cluster.Spec.Bastion != nil {
335337
v1alpha6Cluster.Spec.Bastion.Instance.Image = ""
336338
}
@@ -405,6 +407,8 @@ func TestFuzzyConversion(t *testing.T) {
405407

406408
v1alpha6ClusterTemplate.Spec.Template.Spec.APIServerLoadBalancer.AllowedCIDRs = nil
407409

410+
v1alpha6ClusterTemplate.Spec.Template.Spec.ControlPlaneOmitAvailabilityZone = false
411+
408412
if v1alpha6ClusterTemplate.Spec.Template.Spec.Bastion != nil {
409413
v1alpha6ClusterTemplate.Spec.Template.Spec.Bastion.Instance.Image = ""
410414
}

api/v1alpha4/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha5/conversion.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha5
1818

1919
import (
20+
conversion "k8s.io/apimachinery/pkg/conversion"
2021
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
2122
ctrlconversion "sigs.k8s.io/controller-runtime/pkg/conversion"
2223

@@ -196,3 +197,8 @@ func (r *OpenStackMachineTemplateList) ConvertFrom(srcRaw ctrlconversion.Hub) er
196197

197198
return Convert_v1alpha6_OpenStackMachineTemplateList_To_v1alpha5_OpenStackMachineTemplateList(src, r, nil)
198199
}
200+
201+
func Convert_v1alpha6_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec(in *infrav1.OpenStackClusterSpec, out *OpenStackClusterSpec, s conversion.Scope) error {
202+
// Our new flag has no equivalent in v1alpha5
203+
return autoConvert_v1alpha6_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec(in, out, s)
204+
}

api/v1alpha5/zz_generated.conversion.go

Lines changed: 50 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)