@@ -18,6 +18,7 @@ package options
18
18
19
19
import (
20
20
"fmt"
21
+ "k8s.io/apiserver/pkg/features"
21
22
"net"
22
23
"time"
23
24
@@ -49,8 +50,9 @@ type ServerRunOptions struct {
49
50
// decoded in a write request. 0 means no limit.
50
51
// We intentionally did not add a flag for this option. Users of the
51
52
// apiserver library can wire it to a flag.
52
- MaxRequestBodyBytes int64
53
- TargetRAMMB int
53
+ MaxRequestBodyBytes int64
54
+ TargetRAMMB int
55
+ EnableInfightQuotaHandler bool
54
56
}
55
57
56
58
func NewServerRunOptions () * ServerRunOptions {
@@ -104,11 +106,27 @@ func (s *ServerRunOptions) Validate() []error {
104
106
if s .TargetRAMMB < 0 {
105
107
errors = append (errors , fmt .Errorf ("--target-ram-mb can not be negative value" ))
106
108
}
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
+ }
112
130
}
113
131
114
132
if s .RequestTimeout .Nanoseconds () < 0 {
@@ -174,5 +192,8 @@ func (s *ServerRunOptions) AddUniversalFlags(fs *pflag.FlagSet) {
174
192
"handler, which picks a randomized value above this number as the connection timeout, " +
175
193
"to spread out load." )
176
194
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
+
177
198
utilfeature .DefaultMutableFeatureGate .AddFlag (fs )
178
199
}
0 commit comments