Skip to content

Commit

Permalink
✨ enables explicit disabling of cluster module (#3224)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
RenilRaj-BR authored Nov 4, 2024
1 parent 097c022 commit 34d3698
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions apis/v1alpha3/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func overrideVSphereClusterSpecFieldsFuncs(runtimeserializer.CodecFactory) []int
c.FuzzNoCustom(in)
in.ClusterModules = nil
in.FailureDomainSelector = nil
in.DisableClusterModule = false
},
}
}
Expand Down
1 change: 1 addition & 0 deletions apis/v1alpha3/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/v1alpha4/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func overrideVSphereClusterSpecFieldsFuncs(runtimeserializer.CodecFactory) []int
c.FuzzNoCustom(in)
in.ClusterModules = nil
in.FailureDomainSelector = nil
in.DisableClusterModule = false
},
}
}
Expand Down
1 change: 1 addition & 0 deletions apis/v1alpha4/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions apis/v1beta1/vspherecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ type VSphereClusterSpec struct {
// +optional
ClusterModules []ClusterModule `json:"clusterModules,omitempty"`

// DisableClusterModule is used to explicitly turn off the ClusterModule feature.
// This should work along side NodeAntiAffinity feature flag.
// If the NodeAntiAffinity feature flag is turned off, this will be disregarded.
// +optional
DisableClusterModule bool `json:"disableClusterModule,omitempty"`

// FailureDomainSelector is the label selector to use for failure domain selection
// for the control plane nodes of the cluster.
// If not set (`nil`), selecting failure domains will be disabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,12 @@ spec:
- host
- port
type: object
disableClusterModule:
description: |-
DisableClusterModule is used to explicitly turn off the ClusterModule feature.
This should work along side NodeAntiAffinity feature flag.
If the NodeAntiAffinity feature flag is turned off, this will be disregarded.
type: boolean
failureDomainSelector:
description: |-
FailureDomainSelector is the label selector to use for failure domain selection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ spec:
- host
- port
type: object
disableClusterModule:
description: |-
DisableClusterModule is used to explicitly turn off the ClusterModule feature.
This should work along side NodeAntiAffinity feature flag.
If the NodeAntiAffinity feature flag is turned off, this will be disregarded.
type: boolean
failureDomainSelector:
description: |-
FailureDomainSelector is the label selector to use for failure domain selection
Expand Down
2 changes: 1 addition & 1 deletion controllers/vspherecluster_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (r *clusterReconciler) reconcileDeploymentZones(ctx context.Context, cluste
}

func (r *clusterReconciler) reconcileClusterModules(ctx context.Context, clusterCtx *capvcontext.ClusterContext) (reconcile.Result, error) {
if feature.Gates.Enabled(feature.NodeAntiAffinity) {
if feature.Gates.Enabled(feature.NodeAntiAffinity) && !clusterCtx.VSphereCluster.Spec.DisableClusterModule {
return r.clusterModuleReconciler.Reconcile(ctx, clusterCtx)
}
return reconcile.Result{}, nil
Expand Down
2 changes: 1 addition & 1 deletion controllers/vspherevm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func (r vmReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.R
// This logic was moved to a smaller function outside the main Reconcile() loop
// for the ease of testing.
func (r vmReconciler) reconcile(ctx context.Context, vmCtx *capvcontext.VMContext, input fetchClusterModuleInput) (reconcile.Result, error) {
if feature.Gates.Enabled(feature.NodeAntiAffinity) {
if feature.Gates.Enabled(feature.NodeAntiAffinity) && !input.VSphereCluster.Spec.DisableClusterModule {
clusterModuleInfo, err := r.fetchClusterModuleInfo(ctx, input)
// If cluster module information cannot be fetched for a VM being deleted,
// we should not block VM deletion since the cluster module is updated
Expand Down

0 comments on commit 34d3698

Please sign in to comment.