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 soltysh committed Jul 1, 2024
1 parent d26809c commit 3c8acf1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
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
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 @@ -325,9 +325,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 @@ -751,7 +751,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 @@ -1034,8 +1034,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 @@ -1549,9 +1553,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

0 comments on commit 3c8acf1

Please sign in to comment.