mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
apiserver: fix apf enablement with runtime-config
This commit is contained in:
parent
acd6089659
commit
233bc2449d
@ -56,7 +56,7 @@ func validateAPIPriorityAndFairness(options *Options) []error {
|
||||
// APF is assumed to be turned on. The internal APF controller uses
|
||||
// v1 so it should be enabled.
|
||||
enabledAPIString := options.APIEnablement.RuntimeConfig.String()
|
||||
testConfigs := []string{"flowcontrol.apiserver.k8s.io/v1", "api/all"} // in the order of precedence
|
||||
testConfigs := []string{"flowcontrol.apiserver.k8s.io/v1", "api/ga", "api/all"} // in the order of precedence
|
||||
for _, testConfig := range testConfigs {
|
||||
if strings.Contains(enabledAPIString, fmt.Sprintf("%s=false", testConfig)) {
|
||||
return []error{fmt.Errorf("--runtime-config=%s=false conflicts with --enable-priority-and-fairness=true and --feature-gates=APIPriorityAndFairness=true", testConfig)}
|
||||
|
@ -46,6 +46,14 @@ func TestValidateAPIPriorityAndFairness(t *testing.T) {
|
||||
runtimeConfig: "api/beta=false",
|
||||
errShouldContain: "",
|
||||
},
|
||||
{
|
||||
runtimeConfig: "api/ga=false",
|
||||
errShouldContain: conflict,
|
||||
},
|
||||
{
|
||||
runtimeConfig: "api/ga=true",
|
||||
errShouldContain: "",
|
||||
},
|
||||
{
|
||||
runtimeConfig: "flowcontrol.apiserver.k8s.io/v1beta1=false",
|
||||
errShouldContain: "",
|
||||
@ -70,6 +78,10 @@ func TestValidateAPIPriorityAndFairness(t *testing.T) {
|
||||
runtimeConfig: "flowcontrol.apiserver.k8s.io/v1=false",
|
||||
errShouldContain: conflict,
|
||||
},
|
||||
{
|
||||
runtimeConfig: "flowcontrol.apiserver.k8s.io/v1beta3=true,flowcontrol.apiserver.k8s.io/v1=false",
|
||||
errShouldContain: conflict,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
@ -86,8 +98,16 @@ func TestValidateAPIPriorityAndFairness(t *testing.T) {
|
||||
if errs := validateAPIPriorityAndFairness(options); len(errs) > 0 {
|
||||
errMessageGot = errs[0].Error()
|
||||
}
|
||||
if !strings.Contains(errMessageGot, test.errShouldContain) {
|
||||
t.Errorf("Expected error message to contain: %q, but got: %q", test.errShouldContain, errMessageGot)
|
||||
|
||||
switch {
|
||||
case len(test.errShouldContain) == 0:
|
||||
if len(errMessageGot) > 0 {
|
||||
t.Errorf("Expected no error, but got: %q", errMessageGot)
|
||||
}
|
||||
default:
|
||||
if !strings.Contains(errMessageGot, test.errShouldContain) {
|
||||
t.Errorf("Expected error message to contain: %q, but got: %q", test.errShouldContain, errMessageGot)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user