From 226b43b8ee744aea872288514f8529f90fd6a798 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Wed, 15 Jan 2025 10:32:40 -0500 Subject: [PATCH] Prevent alpha feature gates from being enabled by default Signed-off-by: Davanum Srinivas --- pkg/features/kube_features_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/features/kube_features_test.go b/pkg/features/kube_features_test.go index be847a1f040..3478c55094f 100644 --- a/pkg/features/kube_features_test.go +++ b/pkg/features/kube_features_test.go @@ -73,3 +73,27 @@ func TestAllRegisteredFeaturesExpected(t *testing.T) { } } } +func TestEnsureAlphaGatesAreNotSwitchedOnByDefault(t *testing.T) { + checkAlphaGates := func(feature featuregate.Feature, spec featuregate.FeatureSpec) { + // FIXME(dims): remove this check when WindowsHostNetwork is fixed up or removed + // entirely. Please do NOT add more entries here. + if feature == "WindowsHostNetwork" { + return + } + if spec.PreRelease == featuregate.Alpha && spec.Default { + t.Errorf("The alpha feature gate %q is switched on by default", feature) + } + if spec.PreRelease == featuregate.Alpha && spec.LockToDefault { + t.Errorf("The alpha feature gate %q is locked to default", feature) + } + } + + for feature, spec := range defaultKubernetesFeatureGates { + checkAlphaGates(feature, spec) + } + for feature, specs := range defaultVersionedKubernetesFeatureGates { + for _, spec := range specs { + checkAlphaGates(feature, spec) + } + } +}