Skip to content

Commit ca0c446

Browse files
authored
Merge pull request kubernetes#76413 from yue9944882/chore/feature-gates
Add feature gates for switching between the legacy inflight limiting
2 parents 18b4e1b + 87d0930 commit ca0c446

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

pkg/features/kube_features.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
519519
genericfeatures.APIListChunking: {Default: true, PreRelease: utilfeature.Beta},
520520
genericfeatures.DryRun: {Default: true, PreRelease: utilfeature.Beta},
521521
genericfeatures.ServerSideApply: {Default: false, PreRelease: utilfeature.Alpha},
522+
genericfeatures.RequestManagement: {Default: false, PreRelease: utilfeature.Alpha},
522523

523524
// inherited features from apiextensions-apiserver, relisted here to get a conflict if it is changed
524525
// unintentionally on either side:

staging/src/k8s.io/apiserver/pkg/features/kube_features.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ const (
115115
//
116116
// Enables support for watch bookmark events.
117117
WatchBookmark utilfeature.Feature = "WatchBookmark"
118+
119+
// owner: @MikeSpreitzer @yue9944882
120+
// alpha: v1.15
121+
//
122+
//
123+
// Enables managing request concurrency with prioritization and fairness at each server
124+
RequestManagement utilfeature.Feature = "RequestManagement"
118125
)
119126

120127
func init() {
@@ -137,4 +144,5 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
137144
WinOverlay: {Default: false, PreRelease: utilfeature.Alpha},
138145
WinDSR: {Default: false, PreRelease: utilfeature.Alpha},
139146
WatchBookmark: {Default: false, PreRelease: utilfeature.Alpha},
147+
RequestManagement: {Default: false, PreRelease: utilfeature.Alpha},
140148
}

staging/src/k8s.io/apiserver/pkg/server/options/server_run_options.go

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package options
1818

1919
import (
2020
"fmt"
21+
"k8s.io/apiserver/pkg/features"
2122
"net"
2223
"time"
2324

@@ -49,8 +50,9 @@ type ServerRunOptions struct {
4950
// decoded in a write request. 0 means no limit.
5051
// We intentionally did not add a flag for this option. Users of the
5152
// apiserver library can wire it to a flag.
52-
MaxRequestBodyBytes int64
53-
TargetRAMMB int
53+
MaxRequestBodyBytes int64
54+
TargetRAMMB int
55+
EnableInfightQuotaHandler bool
5456
}
5557

5658
func NewServerRunOptions() *ServerRunOptions {
@@ -104,11 +106,27 @@ func (s *ServerRunOptions) Validate() []error {
104106
if s.TargetRAMMB < 0 {
105107
errors = append(errors, fmt.Errorf("--target-ram-mb can not be negative value"))
106108
}
107-
if s.MaxRequestsInFlight < 0 {
108-
errors = append(errors, fmt.Errorf("--max-requests-inflight can not be negative value"))
109-
}
110-
if s.MaxMutatingRequestsInFlight < 0 {
111-
errors = append(errors, fmt.Errorf("--max-mutating-requests-inflight can not be negative value"))
109+
110+
if s.EnableInfightQuotaHandler {
111+
if !utilfeature.DefaultFeatureGate.Enabled(features.RequestManagement) {
112+
errors = append(errors, fmt.Errorf("--enable-inflight-quota-handler can not be set if feature "+
113+
"gate RequestManagement is disabled"))
114+
}
115+
if s.MaxMutatingRequestsInFlight != 0 {
116+
errors = append(errors, fmt.Errorf("--max-mutating-requests-inflight=%v "+
117+
"can not be set if enabled inflight quota handler", s.MaxMutatingRequestsInFlight))
118+
}
119+
if s.MaxRequestsInFlight != 0 {
120+
errors = append(errors, fmt.Errorf("--max-requests-inflight=%v "+
121+
"can not be set if enabled inflight quota handler", s.MaxRequestsInFlight))
122+
}
123+
} else {
124+
if s.MaxRequestsInFlight < 0 {
125+
errors = append(errors, fmt.Errorf("--max-requests-inflight can not be negative value"))
126+
}
127+
if s.MaxMutatingRequestsInFlight < 0 {
128+
errors = append(errors, fmt.Errorf("--max-mutating-requests-inflight can not be negative value"))
129+
}
112130
}
113131

114132
if s.RequestTimeout.Nanoseconds() < 0 {
@@ -174,5 +192,8 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) {
174192
"handler, which picks a randomized value above this number as the connection timeout, "+
175193
"to spread out load.")
176194

195+
fs.BoolVar(&s.EnableInfightQuotaHandler, "enable-inflight-quota-handler", s.EnableInfightQuotaHandler, ""+
196+
"If true, replace the max-in-flight handler with an enhanced one that queues and dispatches with priority and fairness")
197+
177198
utilfeature.DefaultMutableFeatureGate.AddFlag(fs)
178199
}

0 commit comments

Comments
 (0)