Skip to content

Commit 87a7fa2

Browse files
stttsbertinatto
authored andcommitted
UPSTREAM: <carry>: warn only about unknown feature gates
OpenShift-Rebase-Source: a137009
1 parent adee171 commit 87a7fa2

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
@@ -769,7 +769,9 @@ func TestValidateKubeletConfiguration(t *testing.T) {
769769
conf.FeatureGates["invalid"] = true
770770
return conf
771771
},
772-
errMsg: "unrecognized feature gate: invalid",
772+
// In OpenShift we need to tolerate unrecognized feature gates
773+
// errMsg: "unrecognized feature gate: invalid",
774+
errMsg: "",
773775
},
774776
}
775777

staging/src/k8s.io/component-base/compatibility/registry_test.go

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

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,8 @@ func (f *featureGate) unsafeSetFromMap(enabled map[Feature]bool, m map[string]bo
325325
key := Feature(k)
326326
versionedSpecs, ok := known[key]
327327
if !ok {
328-
// early return if encounters an unknown feature.
329-
errs = append(errs, fmt.Errorf("unrecognized feature gate: %s", k))
330-
return errs
328+
klog.Warningf("unrecognized feature gate: %s", k)
329+
continue
331330
}
332331
featureSpec := featureSpecAtEmulationVersion(versionedSpecs, emulationVersion)
333332
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
@@ -1591,9 +1595,9 @@ func TestCopyKnownFeatures(t *testing.T) {
15911595
require.NoError(t, fcopy.Set("FeatureB=false"))
15921596
assert.True(t, f.Enabled("FeatureB"))
15931597
assert.False(t, fcopy.Enabled("FeatureB"))
1594-
if err := fcopy.Set("FeatureC=true"); err == nil {
1595-
t.Error("expected FeatureC not registered in the copied feature gate")
1596-
}
1598+
// if err := fcopy.Set("FeatureC=true"); err == nil {
1599+
// t.Error("expected FeatureC not registered in the copied feature gate")
1600+
// }
15971601
}
15981602

15991603
func TestExplicitlySet(t *testing.T) {

0 commit comments

Comments
 (0)