From f3f72cbd35879521cedbd0e68b4f14796ae67ee6 Mon Sep 17 00:00:00 2001 From: yue9944882 <291271447@qq.com> Date: Thu, 11 Apr 2019 12:05:31 +0800 Subject: [PATCH 1/2] add feature gates for switching between the legacy inflight limiting Kubernetes-commit: 6630d7c587578864d80ad9cb29b14eca02b8b08a --- pkg/features/kube_features.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index da99c2e66..517c940b5 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -115,6 +115,13 @@ const ( // // Enables support for watch bookmark events. WatchBookmark utilfeature.Feature = "WatchBookmark" + + // owner: @MikeSpreitzer @yue9944882 + // alpha: v1.15 + // + // + // Enables managing request concurrency with prioritization and fairness at each server + RequestManagement utilfeature.Feature = "RequestManagement" ) func init() { @@ -137,4 +144,5 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS WinOverlay: {Default: false, PreRelease: utilfeature.Alpha}, WinDSR: {Default: false, PreRelease: utilfeature.Alpha}, WatchBookmark: {Default: false, PreRelease: utilfeature.Alpha}, + RequestManagement: {Default: false, PreRelease: utilfeature.Alpha}, } From 735ce2f3710c058a8005561f21092f570c76be11 Mon Sep 17 00:00:00 2001 From: yue9944882 <291271447@qq.com> Date: Mon, 15 Apr 2019 14:57:55 +0800 Subject: [PATCH 2/2] add new flag for enabling requests mgmt handler Kubernetes-commit: 87d09301e59ac65e55dba32614b8e8b3bae2dd8f --- pkg/server/options/server_run_options.go | 35 +++++++++++++++++++----- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/pkg/server/options/server_run_options.go b/pkg/server/options/server_run_options.go index 02639bf93..62af780c5 100644 --- a/pkg/server/options/server_run_options.go +++ b/pkg/server/options/server_run_options.go @@ -18,6 +18,7 @@ package options import ( "fmt" + "k8s.io/apiserver/pkg/features" "net" "time" @@ -49,8 +50,9 @@ type ServerRunOptions struct { // decoded in a write request. 0 means no limit. // We intentionally did not add a flag for this option. Users of the // apiserver library can wire it to a flag. - MaxRequestBodyBytes int64 - TargetRAMMB int + MaxRequestBodyBytes int64 + TargetRAMMB int + EnableInfightQuotaHandler bool } func NewServerRunOptions() *ServerRunOptions { @@ -104,11 +106,27 @@ func (s *ServerRunOptions) Validate() []error { if s.TargetRAMMB < 0 { errors = append(errors, fmt.Errorf("--target-ram-mb can not be negative value")) } - if s.MaxRequestsInFlight < 0 { - errors = append(errors, fmt.Errorf("--max-requests-inflight can not be negative value")) - } - if s.MaxMutatingRequestsInFlight < 0 { - errors = append(errors, fmt.Errorf("--max-mutating-requests-inflight can not be negative value")) + + if s.EnableInfightQuotaHandler { + if !utilfeature.DefaultFeatureGate.Enabled(features.RequestManagement) { + errors = append(errors, fmt.Errorf("--enable-inflight-quota-handler can not be set if feature "+ + "gate RequestManagement is disabled")) + } + if s.MaxMutatingRequestsInFlight != 0 { + errors = append(errors, fmt.Errorf("--max-mutating-requests-inflight=%v "+ + "can not be set if enabled inflight quota handler", s.MaxMutatingRequestsInFlight)) + } + if s.MaxRequestsInFlight != 0 { + errors = append(errors, fmt.Errorf("--max-requests-inflight=%v "+ + "can not be set if enabled inflight quota handler", s.MaxRequestsInFlight)) + } + } else { + if s.MaxRequestsInFlight < 0 { + errors = append(errors, fmt.Errorf("--max-requests-inflight can not be negative value")) + } + if s.MaxMutatingRequestsInFlight < 0 { + errors = append(errors, fmt.Errorf("--max-mutating-requests-inflight can not be negative value")) + } } if s.RequestTimeout.Nanoseconds() < 0 { @@ -174,5 +192,8 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) { "handler, which picks a randomized value above this number as the connection timeout, "+ "to spread out load.") + fs.BoolVar(&s.EnableInfightQuotaHandler, "enable-inflight-quota-handler", s.EnableInfightQuotaHandler, ""+ + "If true, replace the max-in-flight handler with an enhanced one that queues and dispatches with priority and fairness") + utilfeature.DefaultMutableFeatureGate.AddFlag(fs) }