Skip to content

Commit 626c3fd

Browse files
stttsbertinatto
authored andcommitted
UPSTREAM: <carry>: warn only about unknown feature gates
OpenShift-Rebase-Source: a137009
1 parent 6a4d042 commit 626c3fd

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

pkg/kubelet/apis/config/validation/validation_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,9 @@ func TestValidateKubeletConfiguration(t *testing.T) {
722722
conf.FeatureGates["invalid"] = true
723723
return conf
724724
},
725-
errMsg: "unrecognized feature gate: invalid",
725+
// In OpenShift we need to tolerate unrecognized feature gates
726+
// errMsg: "unrecognized feature gate: invalid",
727+
errMsg: "",
726728
},
727729
}
728730

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)