Skip to content

Commit

Permalink
UPSTREAM: <carry>: warn only about unknown feature gates
Browse files Browse the repository at this point in the history
OpenShift-Rebase-Source: a137009
  • Loading branch information
sttts authored and bertinatto committed Dec 9, 2024
1 parent 3591fb6 commit 76373bd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 3 additions & 1 deletion pkg/kubelet/apis/config/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,9 @@ func TestValidateKubeletConfiguration(t *testing.T) {
conf.FeatureGates["invalid"] = true
return conf
},
errMsg: "unrecognized feature gate: invalid",
// In OpenShift we need to tolerate unrecognized feature gates
// errMsg: "unrecognized feature gate: invalid",
errMsg: "",
},
}

Expand Down
5 changes: 2 additions & 3 deletions staging/src/k8s.io/component-base/featuregate/feature_gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,8 @@ func (f *featureGate) unsafeSetFromMap(enabled map[Feature]bool, m map[string]bo
key := Feature(k)
versionedSpecs, ok := known[key]
if !ok {
// early return if encounters an unknown feature.
errs = append(errs, fmt.Errorf("unrecognized feature gate: %s", k))
return errs
klog.Warningf("unrecognized feature gate: %s", k)
continue
}
featureSpec := featureSpecAtEmulationVersion(versionedSpecs, emulationVersion)
if featureSpec.LockToDefault && featureSpec.Default != v {
Expand Down
18 changes: 11 additions & 7 deletions staging/src/k8s.io/component-base/featuregate/feature_gate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestFeatureGateFlag(t *testing.T) {
testBetaGate: false,
testLockedFalseGate: false,
},
parseError: "unrecognized feature gate: fooBarBaz",
//parseError: "unrecognized feature gate: fooBarBaz",
},
{
arg: "AllAlpha=false",
Expand Down Expand Up @@ -417,7 +417,7 @@ func TestFeatureGateSetFromMap(t *testing.T) {
testAlphaGate: false,
testBetaGate: false,
},
setmapError: "unrecognized feature gate:",
//setmapError: "unrecognized feature gate:",
},
{
name: "set locked gates",
Expand Down Expand Up @@ -764,7 +764,7 @@ func TestVersionedFeatureGateFlag(t *testing.T) {
testAlphaGateNoVersion: false,
testBetaGateNoVersion: false,
},
parseError: "unrecognized feature gate: fooBarBaz",
// parseError: "unrecognized feature gate: fooBarBaz",
},
{
arg: "AllAlpha=false",
Expand Down Expand Up @@ -1047,8 +1047,12 @@ func TestVersionedFeatureGateFlag(t *testing.T) {
errs = append(errs, err)
}
err = utilerrors.NewAggregate(errs)
strErr := ""
if err != nil {
strErr = err.Error()
}
if test.parseError != "" {
if !strings.Contains(err.Error(), test.parseError) {
if !strings.Contains(strErr, test.parseError) {
t.Errorf("%d: Parse() Expected %v, Got %v", i, test.parseError, err)
}
return
Expand Down Expand Up @@ -1590,9 +1594,9 @@ func TestCopyKnownFeatures(t *testing.T) {
require.NoError(t, fcopy.Set("FeatureB=false"))
assert.True(t, f.Enabled("FeatureB"))
assert.False(t, fcopy.Enabled("FeatureB"))
if err := fcopy.Set("FeatureC=true"); err == nil {
t.Error("expected FeatureC not registered in the copied feature gate")
}
// if err := fcopy.Set("FeatureC=true"); err == nil {
// t.Error("expected FeatureC not registered in the copied feature gate")
// }
}

func TestExplicitlySet(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func TestFlags(t *testing.T) {
"--emulated-version=test=2.7",
"--feature-gates=test:testD=true",
},
parseError: "unrecognized feature gate: testD",
// parseError: "unrecognized feature gate: testD",
},
{
name: "setting unknown component feature flag",
Expand Down

0 comments on commit 76373bd

Please sign in to comment.