Skip to content

Commit 4846757

Browse files
committed
Add feature gate check for vSphere migration support
Gate vSphere migration functionality behind theClusterAPIMachineManagementVSphere feature gate. The migrationcontrollers for vSphere will now only start when both the generalMachineAPIMigration feature gate and the vSphere-specificClusterAPIMachineManagementVSphere feature gate are enabled.
1 parent c016d92 commit 4846757

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

cmd/machine-api-migration/main.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func main() {
9494
}
9595

9696
ctx := ctrl.SetupSignalHandler()
97-
checkFeatureGates(ctx, mgr)
97+
featureGateAccessor := checkFeatureGates(ctx, mgr)
9898

9999
infra, err := util.GetInfra(ctx, mgr.GetAPIReader())
100100
if err != nil {
@@ -113,7 +113,7 @@ func main() {
113113
os.Exit(1)
114114
}
115115

116-
checkPlatformSupported(ctx, platform)
116+
checkPlatformSupported(ctx, platform, featureGateAccessor)
117117

118118
for name, controller := range getControllers(opts, platform, infra, infraTypes) {
119119
if err := controller.SetupWithManager(mgr); err != nil {
@@ -130,7 +130,7 @@ func main() {
130130
}
131131
}
132132

133-
func checkFeatureGates(ctx context.Context, mgr ctrl.Manager) {
133+
func checkFeatureGates(ctx context.Context, mgr ctrl.Manager) featuregates.FeatureGateAccess {
134134
featureGateAccessor, err := getFeatureGates(ctx, mgr)
135135
if err != nil {
136136
klog.Error(err, "unable to get feature gates")
@@ -147,13 +147,27 @@ func checkFeatureGates(ctx context.Context, mgr ctrl.Manager) {
147147
klog.Info("MachineAPIMigration feature gate is not enabled, nothing to do. Waiting for termination signal.")
148148
exitAfterTerminationSignal(ctx)
149149
}
150+
151+
return featureGateAccessor
150152
}
151153

152-
func checkPlatformSupported(ctx context.Context, platform configv1.PlatformType) {
154+
func checkPlatformSupported(ctx context.Context, platform configv1.PlatformType, featureGateAccessor featuregates.FeatureGateAccess) {
153155
switch platform {
154-
case configv1.AWSPlatformType, configv1.OpenStackPlatformType, configv1.VSpherePlatformType:
156+
case configv1.AWSPlatformType, configv1.OpenStackPlatformType:
155157
klog.Infof("MachineAPIMigration: starting %s controllers", platform)
158+
case configv1.VSpherePlatformType:
159+
currentFeatureGates, err := featureGateAccessor.CurrentFeatureGates()
160+
if err != nil {
161+
klog.Error(err, "unable to get current feature gates")
162+
os.Exit(1)
163+
}
156164

165+
if !currentFeatureGates.Enabled(features.FeatureGateClusterAPIMachineManagementVSphere) {
166+
klog.Info("ClusterAPIMachineManagementVSphere feature gate is not enabled for vSphere platform. Waiting for termination signal.")
167+
exitAfterTerminationSignal(ctx)
168+
}
169+
170+
klog.Infof("MachineAPIMigration: starting %s controllers", platform)
157171
default:
158172
klog.Infof("MachineAPIMigration not implemented for platform %s, nothing to do. Waiting for termination signal.", platform)
159173
exitAfterTerminationSignal(ctx)

0 commit comments

Comments
 (0)