Skip to content

Commit 34d3698

Browse files
authored
✨ enables explicit disabling of cluster module (#3224)
* enables explicit disabling of cluster module * adds missing defalut value in the conversion test * skips cluster module during vm reconcile when the disable cluster module is turned on
1 parent 097c022 commit 34d3698

9 files changed

+24
-2
lines changed

apis/v1alpha3/conversion_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func overrideVSphereClusterSpecFieldsFuncs(runtimeserializer.CodecFactory) []int
7979
c.FuzzNoCustom(in)
8080
in.ClusterModules = nil
8181
in.FailureDomainSelector = nil
82+
in.DisableClusterModule = false
8283
},
8384
}
8485
}

apis/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.

apis/v1alpha4/conversion_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func overrideVSphereClusterSpecFieldsFuncs(runtimeserializer.CodecFactory) []int
7070
c.FuzzNoCustom(in)
7171
in.ClusterModules = nil
7272
in.FailureDomainSelector = nil
73+
in.DisableClusterModule = false
7374
},
7475
}
7576
}

apis/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.

apis/v1beta1/vspherecluster_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ type VSphereClusterSpec struct {
5959
// +optional
6060
ClusterModules []ClusterModule `json:"clusterModules,omitempty"`
6161

62+
// DisableClusterModule is used to explicitly turn off the ClusterModule feature.
63+
// This should work along side NodeAntiAffinity feature flag.
64+
// If the NodeAntiAffinity feature flag is turned off, this will be disregarded.
65+
// +optional
66+
DisableClusterModule bool `json:"disableClusterModule,omitempty"`
67+
6268
// FailureDomainSelector is the label selector to use for failure domain selection
6369
// for the control plane nodes of the cluster.
6470
// If not set (`nil`), selecting failure domains will be disabled.

config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusters.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,12 @@ spec:
694694
- host
695695
- port
696696
type: object
697+
disableClusterModule:
698+
description: |-
699+
DisableClusterModule is used to explicitly turn off the ClusterModule feature.
700+
This should work along side NodeAntiAffinity feature flag.
701+
If the NodeAntiAffinity feature flag is turned off, this will be disregarded.
702+
type: boolean
697703
failureDomainSelector:
698704
description: |-
699705
FailureDomainSelector is the label selector to use for failure domain selection

config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclustertemplates.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ spec:
180180
- host
181181
- port
182182
type: object
183+
disableClusterModule:
184+
description: |-
185+
DisableClusterModule is used to explicitly turn off the ClusterModule feature.
186+
This should work along side NodeAntiAffinity feature flag.
187+
If the NodeAntiAffinity feature flag is turned off, this will be disregarded.
188+
type: boolean
183189
failureDomainSelector:
184190
description: |-
185191
FailureDomainSelector is the label selector to use for failure domain selection

controllers/vspherecluster_reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ func (r *clusterReconciler) reconcileDeploymentZones(ctx context.Context, cluste
359359
}
360360

361361
func (r *clusterReconciler) reconcileClusterModules(ctx context.Context, clusterCtx *capvcontext.ClusterContext) (reconcile.Result, error) {
362-
if feature.Gates.Enabled(feature.NodeAntiAffinity) {
362+
if feature.Gates.Enabled(feature.NodeAntiAffinity) && !clusterCtx.VSphereCluster.Spec.DisableClusterModule {
363363
return r.clusterModuleReconciler.Reconcile(ctx, clusterCtx)
364364
}
365365
return reconcile.Result{}, nil

controllers/vspherevm_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func (r vmReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.R
314314
// This logic was moved to a smaller function outside the main Reconcile() loop
315315
// for the ease of testing.
316316
func (r vmReconciler) reconcile(ctx context.Context, vmCtx *capvcontext.VMContext, input fetchClusterModuleInput) (reconcile.Result, error) {
317-
if feature.Gates.Enabled(feature.NodeAntiAffinity) {
317+
if feature.Gates.Enabled(feature.NodeAntiAffinity) && !input.VSphereCluster.Spec.DisableClusterModule {
318318
clusterModuleInfo, err := r.fetchClusterModuleInfo(ctx, input)
319319
// If cluster module information cannot be fetched for a VM being deleted,
320320
// we should not block VM deletion since the cluster module is updated

0 commit comments

Comments
 (0)