Skip to content

Commit

Permalink
add MachineSetPreflightChecks feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuvaraj Kakaraparthi committed May 20, 2023
1 parent 7b90d05 commit c21ccfb
Show file tree
Hide file tree
Showing 4 changed files with 361 additions and 303 deletions.
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
args:
- "--leader-elect"
- "--metrics-bind-addr=localhost:8080"
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},ClusterResourceSet=${EXP_CLUSTER_RESOURCE_SET:=false},ClusterTopology=${CLUSTER_TOPOLOGY:=false},RuntimeSDK=${EXP_RUNTIME_SDK:=false},LazyRestmapper=${EXP_LAZY_RESTMAPPER:=false}"
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=false},ClusterResourceSet=${EXP_CLUSTER_RESOURCE_SET:=false},ClusterTopology=${CLUSTER_TOPOLOGY:=false},RuntimeSDK=${EXP_RUNTIME_SDK:=false},LazyRestmapper=${EXP_LAZY_RESTMAPPER:=false},MachineSetPreflightChecks=${MACHINESET_PREFLIGHT_CHECKS:=false}"
image: controller:latest
name: manager
env:
Expand Down
6 changes: 6 additions & 0 deletions feature/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ const (
//
// alpha: v1.4
LazyRestmapper featuregate.Feature = "LazyRestmapper"

// MachineSetPreflightChecks is a feature fate for the MachineSet preflight checks functionality.
//
// alpha: v1.5
MachineSetPreflightChecks featuregate.Feature = "MachineSetPreflightChecks"
)

func init() {
Expand All @@ -76,4 +81,5 @@ var defaultClusterAPIFeatureGates = map[featuregate.Feature]featuregate.FeatureS
KubeadmBootstrapFormatIgnition: {Default: false, PreRelease: featuregate.Alpha},
RuntimeSDK: {Default: false, PreRelease: featuregate.Alpha},
LazyRestmapper: {Default: false, PreRelease: featuregate.Alpha},
MachineSetPreflightChecks: {Default: false, PreRelease: featuregate.Alpha},
}
6 changes: 6 additions & 0 deletions internal/controllers/machineset/machineset_preflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
"sigs.k8s.io/cluster-api/controllers/external"
"sigs.k8s.io/cluster-api/feature"
"sigs.k8s.io/cluster-api/internal/contract"
"sigs.k8s.io/cluster-api/util"
)
Expand All @@ -43,6 +44,11 @@ import (
const preflightFailedRequeueAfter = 15 * time.Second

func (r *Reconciler) runPreflightChecks(ctx context.Context, cluster *clusterv1.Cluster, ms *clusterv1.MachineSet) (ctrl.Result, error) {
// If the MachineSetPreflightChecks feature gate is disabled return early.
if !feature.Gates.Enabled(feature.MachineSetPreflightChecks) {
return ctrl.Result{}, nil
}

skipped := skippedPreflightChecks(ms)
// If all the preflight checks are skipped then return early.
if skipped.Has(clusterv1.MachineSetPreflightCheckAll) {
Expand Down
Loading

0 comments on commit c21ccfb

Please sign in to comment.