diff --git a/pkg/controlplane/apiserver/options/validation.go b/pkg/controlplane/apiserver/options/validation.go index c62b9703445..228e6e78231 100644 --- a/pkg/controlplane/apiserver/options/validation.go +++ b/pkg/controlplane/apiserver/options/validation.go @@ -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)} diff --git a/pkg/controlplane/apiserver/options/validation_test.go b/pkg/controlplane/apiserver/options/validation_test.go index 7ab4e28fc2c..2fe9b2fc945 100644 --- a/pkg/controlplane/apiserver/options/validation_test.go +++ b/pkg/controlplane/apiserver/options/validation_test.go @@ -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) + } } }) }