Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5dc3c7f

Browse files
stttsbertinatto
authored andcommittedNov 28, 2024
UPSTREAM: <carry>: warn only about unknown feature gates
OpenShift-Rebase-Source: a137009
1 parent 694b557 commit 5dc3c7f

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed
 

‎staging/src/k8s.io/component-base/featuregate/feature_gate.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,8 @@ func (f *featureGate) unsafeSetFromMap(enabled map[Feature]bool, m map[string]bo
327327
key := Feature(k)
328328
versionedSpecs, ok := known[key]
329329
if !ok {
330-
// early return if encounters an unknown feature.
331-
errs = append(errs, fmt.Errorf("unrecognized feature gate: %s", k))
332-
return errs
330+
klog.Warningf("unrecognized feature gate: %s", k)
331+
continue
333332
}
334333
featureSpec := featureSpecAtEmulationVersion(versionedSpecs, emulationVersion)
335334
if featureSpec.LockToDefault && featureSpec.Default != v {

‎staging/src/k8s.io/component-base/featuregate/feature_gate_test.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func TestFeatureGateFlag(t *testing.T) {
8888
testBetaGate: false,
8989
testLockedFalseGate: false,
9090
},
91-
parseError: "unrecognized feature gate: fooBarBaz",
91+
//parseError: "unrecognized feature gate: fooBarBaz",
9292
},
9393
{
9494
arg: "AllAlpha=false",
@@ -417,7 +417,7 @@ func TestFeatureGateSetFromMap(t *testing.T) {
417417
testAlphaGate: false,
418418
testBetaGate: false,
419419
},
420-
setmapError: "unrecognized feature gate:",
420+
//setmapError: "unrecognized feature gate:",
421421
},
422422
{
423423
name: "set locked gates",
@@ -764,7 +764,7 @@ func TestVersionedFeatureGateFlag(t *testing.T) {
764764
testAlphaGateNoVersion: false,
765765
testBetaGateNoVersion: false,
766766
},
767-
parseError: "unrecognized feature gate: fooBarBaz",
767+
// parseError: "unrecognized feature gate: fooBarBaz",
768768
},
769769
{
770770
arg: "AllAlpha=false",
@@ -1047,8 +1047,12 @@ func TestVersionedFeatureGateFlag(t *testing.T) {
10471047
errs = append(errs, err)
10481048
}
10491049
err = utilerrors.NewAggregate(errs)
1050+
strErr := ""
1051+
if err != nil {
1052+
strErr = err.Error()
1053+
}
10501054
if test.parseError != "" {
1051-
if !strings.Contains(err.Error(), test.parseError) {
1055+
if !strings.Contains(strErr, test.parseError) {
10521056
t.Errorf("%d: Parse() Expected %v, Got %v", i, test.parseError, err)
10531057
}
10541058
return
@@ -1590,9 +1594,9 @@ func TestCopyKnownFeatures(t *testing.T) {
15901594
require.NoError(t, fcopy.Set("FeatureB=false"))
15911595
assert.True(t, f.Enabled("FeatureB"))
15921596
assert.False(t, fcopy.Enabled("FeatureB"))
1593-
if err := fcopy.Set("FeatureC=true"); err == nil {
1594-
t.Error("expected FeatureC not registered in the copied feature gate")
1595-
}
1597+
// if err := fcopy.Set("FeatureC=true"); err == nil {
1598+
// t.Error("expected FeatureC not registered in the copied feature gate")
1599+
// }
15961600
}
15971601

15981602
func TestExplicitlySet(t *testing.T) {

‎staging/src/k8s.io/component-base/featuregate/registry_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func TestFlags(t *testing.T) {
261261
"--emulated-version=test=2.7",
262262
"--feature-gates=test:testD=true",
263263
},
264-
parseError: "unrecognized feature gate: testD",
264+
// parseError: "unrecognized feature gate: testD",
265265
},
266266
{
267267
name: "setting unknown component feature flag",

0 commit comments

Comments
 (0)
Please sign in to comment.