From c7fcef187562e1b3ffdaa2e2109c65d800b8f5d5 Mon Sep 17 00:00:00 2001 From: Abu Kashem Date: Tue, 31 Oct 2023 08:35:52 -0400 Subject: [PATCH] apiserver: set APF featuregate to ga --- pkg/controlplane/apiserver/options/validation.go | 4 ++-- pkg/controlplane/apiserver/options/validation_test.go | 2 +- pkg/features/kube_features.go | 2 +- staging/src/k8s.io/apiserver/pkg/features/kube_features.go | 3 ++- staging/src/k8s.io/apiserver/pkg/server/config.go | 2 +- staging/src/k8s.io/apiserver/pkg/server/options/feature.go | 6 ++---- test/integration/apiserver/flowcontrol/concurrency_test.go | 5 ----- .../apiserver/flowcontrol/concurrency_util_test.go | 6 ------ test/integration/apiserver/flowcontrol/fight_test.go | 4 ---- test/integration/apiserver/flowcontrol/fs_condition_test.go | 5 ----- 10 files changed, 9 insertions(+), 30 deletions(-) diff --git a/pkg/controlplane/apiserver/options/validation.go b/pkg/controlplane/apiserver/options/validation.go index 228e6e78231..1cae7323ab1 100644 --- a/pkg/controlplane/apiserver/options/validation.go +++ b/pkg/controlplane/apiserver/options/validation.go @@ -51,7 +51,7 @@ func validateTokenRequest(options *Options) []error { } func validateAPIPriorityAndFairness(options *Options) []error { - if utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIPriorityAndFairness) && options.Features.EnablePriorityAndFairness { + if options.Features.EnablePriorityAndFairness { // If none of the following runtime config options are specified, // APF is assumed to be turned on. The internal APF controller uses // v1 so it should be enabled. @@ -59,7 +59,7 @@ func validateAPIPriorityAndFairness(options *Options) []error { 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)} + return []error{fmt.Errorf("--runtime-config=%s=false conflicts with --enable-priority-and-fairness=true", testConfig)} } if strings.Contains(enabledAPIString, fmt.Sprintf("%s=true", testConfig)) { return nil diff --git a/pkg/controlplane/apiserver/options/validation_test.go b/pkg/controlplane/apiserver/options/validation_test.go index 2fe9b2fc945..c4f7ab233bd 100644 --- a/pkg/controlplane/apiserver/options/validation_test.go +++ b/pkg/controlplane/apiserver/options/validation_test.go @@ -33,7 +33,7 @@ import ( ) func TestValidateAPIPriorityAndFairness(t *testing.T) { - const conflict = "conflicts with --enable-priority-and-fairness=true and --feature-gates=APIPriorityAndFairness=true" + const conflict = "conflicts with --enable-priority-and-fairness=true" tests := []struct { runtimeConfig string errShouldContain string diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index cbbbcc3437d..334a3caddca 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -1195,7 +1195,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS genericfeatures.APIListChunking: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.32 - genericfeatures.APIPriorityAndFairness: {Default: true, PreRelease: featuregate.Beta}, + genericfeatures.APIPriorityAndFairness: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.31 genericfeatures.APIResponseCompression: {Default: true, PreRelease: featuregate.Beta}, diff --git a/staging/src/k8s.io/apiserver/pkg/features/kube_features.go b/staging/src/k8s.io/apiserver/pkg/features/kube_features.go index e157518f5cb..f059cef9bc8 100644 --- a/staging/src/k8s.io/apiserver/pkg/features/kube_features.go +++ b/staging/src/k8s.io/apiserver/pkg/features/kube_features.go @@ -63,6 +63,7 @@ const ( // owner: @MikeSpreitzer @yue9944882 // alpha: v1.18 // beta: v1.20 + // stable: 1.29 // // Enables managing request concurrency with prioritization and fairness at each server. // The FeatureGate was introduced in release 1.15 but the feature @@ -276,7 +277,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS APIListChunking: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.32 - APIPriorityAndFairness: {Default: true, PreRelease: featuregate.Beta}, + APIPriorityAndFairness: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.31 APIResponseCompression: {Default: true, PreRelease: featuregate.Beta}, diff --git a/staging/src/k8s.io/apiserver/pkg/server/config.go b/staging/src/k8s.io/apiserver/pkg/server/config.go index 0b5781f4b96..beff08f14d0 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/config.go +++ b/staging/src/k8s.io/apiserver/pkg/server/config.go @@ -1084,7 +1084,7 @@ func installAPI(s *GenericAPIServer, c *Config) { s.Handler.GoRestfulContainer.Add(s.DiscoveryGroupManager.WebService()) } } - if c.FlowControl != nil && utilfeature.DefaultFeatureGate.Enabled(genericfeatures.APIPriorityAndFairness) { + if c.FlowControl != nil { c.FlowControl.Install(s.Handler.NonGoRestfulMux) } } diff --git a/staging/src/k8s.io/apiserver/pkg/server/options/feature.go b/staging/src/k8s.io/apiserver/pkg/server/options/feature.go index f484be0b570..f01195560a4 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/options/feature.go +++ b/staging/src/k8s.io/apiserver/pkg/server/options/feature.go @@ -22,9 +22,7 @@ import ( "github.com/spf13/pflag" "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/apiserver/pkg/features" "k8s.io/apiserver/pkg/server" - "k8s.io/apiserver/pkg/util/feature" utilflowcontrol "k8s.io/apiserver/pkg/util/flowcontrol" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" @@ -60,7 +58,7 @@ func (o *FeatureOptions) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&o.DebugSocketPath, "debug-socket-path", o.DebugSocketPath, "Use an unprotected (no authn/authz) unix-domain socket for profiling with the given path") fs.BoolVar(&o.EnablePriorityAndFairness, "enable-priority-and-fairness", o.EnablePriorityAndFairness, ""+ - "If true and the APIPriorityAndFairness feature gate is enabled, replace the max-in-flight handler with an enhanced one that queues and dispatches with priority and fairness") + "If true, replace the max-in-flight handler with an enhanced one that queues and dispatches with priority and fairness") } func (o *FeatureOptions) ApplyTo(c *server.Config, clientset kubernetes.Interface, informers informers.SharedInformerFactory) error { @@ -72,7 +70,7 @@ func (o *FeatureOptions) ApplyTo(c *server.Config, clientset kubernetes.Interfac c.DebugSocketPath = o.DebugSocketPath c.EnableContentionProfiling = o.EnableContentionProfiling - if o.EnablePriorityAndFairness && feature.DefaultFeatureGate.Enabled(features.APIPriorityAndFairness) { + if o.EnablePriorityAndFairness { if c.MaxRequestsInFlight+c.MaxMutatingRequestsInFlight <= 0 { return fmt.Errorf("invalid configuration: MaxRequestsInFlight=%d and MaxMutatingRequestsInFlight=%d; they must add up to something positive", c.MaxRequestsInFlight, c.MaxMutatingRequestsInFlight) diff --git a/test/integration/apiserver/flowcontrol/concurrency_test.go b/test/integration/apiserver/flowcontrol/concurrency_test.go index 203f2f90231..4a183ecfde2 100644 --- a/test/integration/apiserver/flowcontrol/concurrency_test.go +++ b/test/integration/apiserver/flowcontrol/concurrency_test.go @@ -31,11 +31,8 @@ import ( flowcontrol "k8s.io/api/flowcontrol/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" - genericfeatures "k8s.io/apiserver/pkg/features" - utilfeature "k8s.io/apiserver/pkg/util/feature" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" - featuregatetesting "k8s.io/component-base/featuregate/testing" "k8s.io/kubernetes/cmd/kube-apiserver/app/options" "k8s.io/kubernetes/test/integration/framework" "k8s.io/kubernetes/test/utils/ktesting" @@ -71,8 +68,6 @@ func setup(t testing.TB, maxReadonlyRequestsInFlight, maxMutatingRequestsInFligh } func TestPriorityLevelIsolation(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.APIPriorityAndFairness, true)() - // NOTE: disabling the feature should fail the test ctx, kubeConfig, closeFn := setup(t, 1, 1) defer closeFn() diff --git a/test/integration/apiserver/flowcontrol/concurrency_util_test.go b/test/integration/apiserver/flowcontrol/concurrency_util_test.go index ba5c88f31bf..8b913130da2 100644 --- a/test/integration/apiserver/flowcontrol/concurrency_util_test.go +++ b/test/integration/apiserver/flowcontrol/concurrency_util_test.go @@ -31,10 +31,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apiserver/pkg/authorization/authorizer" - genericfeatures "k8s.io/apiserver/pkg/features" - utilfeature "k8s.io/apiserver/pkg/util/feature" clientset "k8s.io/client-go/kubernetes" - featuregatetesting "k8s.io/component-base/featuregate/testing" "k8s.io/kubernetes/cmd/kube-apiserver/app/options" "k8s.io/kubernetes/pkg/controlplane" "k8s.io/kubernetes/test/integration/framework" @@ -152,9 +149,6 @@ func TestConcurrencyIsolation(t *testing.T) { ctx, cancel := context.WithCancel(ctx) defer cancel() - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.APIPriorityAndFairness, true)() - // NOTE: disabling the feature should fail the test - _, kubeConfig, closeFn := framework.StartTestServer(ctx, t, framework.TestServerSetup{ ModifyServerRunOptions: func(opts *options.ServerRunOptions) { // Ensure all clients are allowed to send requests. diff --git a/test/integration/apiserver/flowcontrol/fight_test.go b/test/integration/apiserver/flowcontrol/fight_test.go index bca0fa52a75..c0961795692 100644 --- a/test/integration/apiserver/flowcontrol/fight_test.go +++ b/test/integration/apiserver/flowcontrol/fight_test.go @@ -26,8 +26,6 @@ import ( "time" flowcontrol "k8s.io/api/flowcontrol/v1" - genericfeatures "k8s.io/apiserver/pkg/features" - utilfeature "k8s.io/apiserver/pkg/util/feature" utilfc "k8s.io/apiserver/pkg/util/flowcontrol" fqtesting "k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/testing" "k8s.io/apiserver/pkg/util/flowcontrol/metrics" @@ -35,7 +33,6 @@ import ( clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/client-go/tools/cache" - featuregatetesting "k8s.io/component-base/featuregate/testing" "k8s.io/utils/clock" testclocks "k8s.io/utils/clock/testing" ) @@ -170,7 +167,6 @@ func (ft *fightTest) evaluate(tBeforeCreate, tAfterCreate time.Time) { } } func TestConfigConsumerFight(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.APIPriorityAndFairness, true)() _, kubeConfig, closeFn := setup(t, 100, 100) defer closeFn() const teamSize = 3 diff --git a/test/integration/apiserver/flowcontrol/fs_condition_test.go b/test/integration/apiserver/flowcontrol/fs_condition_test.go index 7ecffe0073a..7bac126c021 100644 --- a/test/integration/apiserver/flowcontrol/fs_condition_test.go +++ b/test/integration/apiserver/flowcontrol/fs_condition_test.go @@ -26,17 +26,12 @@ import ( machinerytypes "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" fcboot "k8s.io/apiserver/pkg/apis/flowcontrol/bootstrap" - genericfeatures "k8s.io/apiserver/pkg/features" - utilfeature "k8s.io/apiserver/pkg/util/feature" flowcontrolapply "k8s.io/client-go/applyconfigurations/flowcontrol/v1" clientset "k8s.io/client-go/kubernetes" - featuregatetesting "k8s.io/component-base/featuregate/testing" "k8s.io/klog/v2" ) func TestConditionIsolation(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.APIPriorityAndFairness, true)() - // NOTE: disabling the feature should fail the test ctx, kubeConfig, closeFn := setup(t, 10, 10) defer closeFn()