mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
update api enablement for flowcontrol v1beta3
This commit is contained in:
parent
0a99e6ebb1
commit
6dc81c3280
@ -124,10 +124,11 @@ func validateTokenRequest(options *ServerRunOptions) []error {
|
|||||||
|
|
||||||
func validateAPIPriorityAndFairness(options *ServerRunOptions) []error {
|
func validateAPIPriorityAndFairness(options *ServerRunOptions) []error {
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIPriorityAndFairness) && options.GenericServerRunOptions.EnablePriorityAndFairness {
|
if utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIPriorityAndFairness) && options.GenericServerRunOptions.EnablePriorityAndFairness {
|
||||||
// If none of the following runtime config options are specified, APF is
|
// If none of the following runtime config options are specified,
|
||||||
// assumed to be turned on.
|
// APF is assumed to be turned on. The internal APF controller uses
|
||||||
|
// v1beta3 so it should be enabled.
|
||||||
enabledAPIString := options.APIEnablement.RuntimeConfig.String()
|
enabledAPIString := options.APIEnablement.RuntimeConfig.String()
|
||||||
testConfigs := []string{"flowcontrol.apiserver.k8s.io/v1beta2", "flowcontrol.apiserver.k8s.io/v1beta1", "api/beta", "api/all"} // in the order of precedence
|
testConfigs := []string{"flowcontrol.apiserver.k8s.io/v1beta3", "api/beta", "api/all"} // in the order of precedence
|
||||||
for _, testConfig := range testConfigs {
|
for _, testConfig := range testConfigs {
|
||||||
if strings.Contains(enabledAPIString, fmt.Sprintf("%s=false", testConfig)) {
|
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)}
|
return []error{fmt.Errorf("--runtime-config=%s=false conflicts with --enable-priority-and-fairness=true and --feature-gates=APIPriorityAndFairness=true", testConfig)}
|
||||||
|
@ -18,9 +18,11 @@ package options
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
utilnet "k8s.io/apimachinery/pkg/util/net"
|
utilnet "k8s.io/apimachinery/pkg/util/net"
|
||||||
|
genericoptions "k8s.io/apiserver/pkg/server/options"
|
||||||
netutils "k8s.io/utils/net"
|
netutils "k8s.io/utils/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -250,3 +252,52 @@ func TestValidateMaxCIDRRange(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestValidateAPIPriorityAndFairness(t *testing.T) {
|
||||||
|
const conflict = "conflicts with --enable-priority-and-fairness=true and --feature-gates=APIPriorityAndFairness=true"
|
||||||
|
tests := []struct {
|
||||||
|
runtimeConfig string
|
||||||
|
errShouldContain string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
runtimeConfig: "api/all=false",
|
||||||
|
errShouldContain: conflict,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
runtimeConfig: "api/beta=false",
|
||||||
|
errShouldContain: conflict,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
runtimeConfig: "flowcontrol.apiserver.k8s.io/v1beta1=false",
|
||||||
|
errShouldContain: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
runtimeConfig: "flowcontrol.apiserver.k8s.io/v1beta2=false",
|
||||||
|
errShouldContain: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
runtimeConfig: "flowcontrol.apiserver.k8s.io/v1beta3=false",
|
||||||
|
errShouldContain: conflict,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.runtimeConfig, func(t *testing.T) {
|
||||||
|
options := &ServerRunOptions{
|
||||||
|
GenericServerRunOptions: &genericoptions.ServerRunOptions{
|
||||||
|
EnablePriorityAndFairness: true,
|
||||||
|
},
|
||||||
|
APIEnablement: genericoptions.NewAPIEnablementOptions(),
|
||||||
|
}
|
||||||
|
options.APIEnablement.RuntimeConfig.Set(test.runtimeConfig)
|
||||||
|
|
||||||
|
var errMessageGot string
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user