From feae5f3e79e1b625f58240110f5d530149822396 Mon Sep 17 00:00:00 2001 From: Mike Spreitzer Date: Mon, 21 Jun 2021 16:53:07 -0400 Subject: [PATCH] Add config checking for inflight limits When API Priority and Fairness is enabled, the inflight limits must add up to something positive. This rejects the configuration that prompted https://github.com/kubernetes/kubernetes/issues/102885 Update help for max inflight flags Kubernetes-commit: 0762f492c5b850471723a305cfa7390e44851145 --- pkg/server/options/recommended.go | 6 ++++++ pkg/server/options/server_run_options.go | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/pkg/server/options/recommended.go b/pkg/server/options/recommended.go index 859dc88cb..e15191cb9 100644 --- a/pkg/server/options/recommended.go +++ b/pkg/server/options/recommended.go @@ -17,6 +17,8 @@ limitations under the License. package options import ( + "fmt" + "github.com/spf13/pflag" "k8s.io/apimachinery/pkg/runtime" @@ -126,6 +128,10 @@ func (o *RecommendedOptions) ApplyTo(config *server.RecommendedConfig) error { } if feature.DefaultFeatureGate.Enabled(features.APIPriorityAndFairness) { if config.ClientConfig != nil { + if config.MaxRequestsInFlight+config.MaxMutatingRequestsInFlight <= 0 { + return fmt.Errorf("invalid configuration: MaxRequestsInFlight=%d and MaxMutatingRequestsInFlight=%d; they must add up to something positive", config.MaxRequestsInFlight, config.MaxMutatingRequestsInFlight) + + } config.FlowControl = utilflowcontrol.New( config.SharedInformerFactory, kubernetes.NewForConfigOrDie(config.ClientConfig).FlowcontrolV1beta1(), diff --git a/pkg/server/options/server_run_options.go b/pkg/server/options/server_run_options.go index b9080fa81..9758eec11 100644 --- a/pkg/server/options/server_run_options.go +++ b/pkg/server/options/server_run_options.go @@ -204,12 +204,16 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) { "DEPRECATED: the namespace from which the Kubernetes master services should be injected into pods.") fs.IntVar(&s.MaxRequestsInFlight, "max-requests-inflight", s.MaxRequestsInFlight, ""+ - "The maximum number of non-mutating requests in flight at a given time. When the server exceeds this, "+ - "it rejects requests. Zero for no limit.") + "This and --max-mutating-requests-inflight are summed to determine the server's total concurrency limit "+ + "(which must be positive) if --enable-priority-and-fairness is true. "+ + "Otherwise, this flag limits the maximum number of non-mutating requests in flight, "+ + "or a zero value disables the limit completely.") fs.IntVar(&s.MaxMutatingRequestsInFlight, "max-mutating-requests-inflight", s.MaxMutatingRequestsInFlight, ""+ - "The maximum number of mutating requests in flight at a given time. When the server exceeds this, "+ - "it rejects requests. Zero for no limit.") + "This and --max-requests-inflight are summed to determine the server's total concurrency limit "+ + "(which must be positive) if --enable-priority-and-fairness is true. "+ + "Otherwise, this flag limits the maximum number of mutating requests in flight, "+ + "or a zero value disables the limit completely.") fs.DurationVar(&s.RequestTimeout, "request-timeout", s.RequestTimeout, ""+ "An optional field indicating the duration a handler must keep a request open before timing "+