Skip to content

Commit

Permalink
Refactored PriorityLevelConfiguration
Browse files Browse the repository at this point in the history
.. so that concurrency limitation can be done without queuing
(like the existing max-in-flight filter does).
  • Loading branch information
MikeSpreitzer committed Nov 13, 2019
1 parent be1658e commit f9bc2bc
Show file tree
Hide file tree
Showing 13 changed files with 1,096 additions and 327 deletions.
67 changes: 55 additions & 12 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 73 additions & 27 deletions pkg/apis/flowcontrol/types.go
Expand Up @@ -320,44 +320,53 @@ type PriorityLevelConfigurationList struct {
Items []PriorityLevelConfiguration
}

// PriorityLevelConfigurationSpec is specification of a priority level
// PriorityLevelConfigurationSpec specifies the configuration of a priority level.
// +union
type PriorityLevelConfigurationSpec struct {
// `type` indicates whether this priority level does
// queuing or is exempt. Valid values are "Queuing" and "Exempt".
// "Exempt" means that requests of this priority level are not subject
// to concurrency limits (and thus are never queued) and do not detract
// from the concurrency available for non-exempt requests. The "Exempt"
// type is useful for apiserver self-requests and system administrator use.
// `type` indicates whether this priority level is subject to
// limitation on request execution. A value of `"Exempt"` means
// that requests of this priority level are not subject to a limit
// (and thus are never queued) and do not detract from the
// capacity made available to other priority levels. A value of
// `"Limited"` means that (a) requests of this priority level
// _are_ subject to limits and (b) some of the server's limited
// capacity is made available exclusively to this priority level.
// Required.
Type PriorityLevelQueueingType
// +unionDiscriminator
Type PriorityLevelEnablement

// `queuing` holds the configuration parameters that are
// only meaningful for a priority level that does queuing (i.e.,
// is not exempt). This field must be non-empty if and only if
// `queuingType` is `"Queuing"`.
// `limited` specifies how requests are handled for a Limited priority level.
// This field must be non-empty if and only if `type` is `"Limited"`.
// +optional
Queuing *QueuingConfiguration
Limited *LimitedPriorityLevelConfiguration
}

// PriorityLevelQueueingType identifies the queuing nature of a priority level
type PriorityLevelQueueingType string
// PriorityLevelEnablement indicates whether limits on execution are enabled for the priority level
type PriorityLevelEnablement string

// Supported queuing types.
// Supported priority level enablement values.
const (
// PriorityLevelQueuingTypeQueueing is the PriorityLevelQueueingType for priority levels that queue
PriorityLevelQueuingTypeQueueing PriorityLevelQueueingType = "Queuing"
// PriorityLevelEnablementExempt means that requests are not subject to limits
PriorityLevelEnablementExempt PriorityLevelEnablement = "Exempt"

// PriorityLevelQueuingTypeExempt is the PriorityLevelQueueingType for priority levels that are exempt from concurrency controls
PriorityLevelQueuingTypeExempt PriorityLevelQueueingType = "Exempt"
// PriorityLevelEnablementLimited means that requests are subject to limits
PriorityLevelEnablementLimited PriorityLevelEnablement = "Limited"
)

// QueuingConfiguration holds the configuration parameters that are specific to a priority level that is subject to concurrency controls
type QueuingConfiguration struct {
// `assuredConcurrencyShares` (ACS) must be a positive number. The
// server's concurrency limit (SCL) is divided among the
// concurrency-controlled priority levels in proportion to their
// assured concurrency shares. This produces the assured
// concurrency value (ACV) for each such priority level:
// LimitedPriorityLevelConfiguration specifies how to handle requests that are subject to limits.
// It addresses two issues:
// * How are requests for this priority level limited?
// * What should be done with requests that exceed the limit?
type LimitedPriorityLevelConfiguration struct {
// `assuredConcurrencyShares` (ACS) configures the execution
// limit, which is a limit on the number of requests of this
// priority level that may be exeucting at a given time. ACS must
// be a positive number. The server's concurrency limit (SCL) is
// divided among the concurrency-controlled priority levels in
// proportion to their assured concurrency shares. This produces
// the assured concurrency value (ACV) --- the number of requests
// that may be executing at a time --- for each such priority
// level:
//
// ACV(l) = ceil( SCL * ACS(l) / ( sum[priority levels k] ACS(k) ) )
//
Expand All @@ -367,6 +376,43 @@ type QueuingConfiguration struct {
// +optional
AssuredConcurrencyShares int32

// `limitResponse` indicates what to do with requests that can not be executed right now
LimitResponse LimitResponse
}

// LimitResponse defines how to handle requests that can not be executed right now.
// +union
type LimitResponse struct {
// `type` is "Queue" or "Reject".
// "Queue" means that requests that can not be executed upon arrival
// are held in a queue until they can be executed or a queuing limit
// is reached.
// "Reject" means that requests that can not be executed upon arrival
// are rejected.
// Required.
// +unionDiscriminator
Type LimitResponseType

// `queuing` holds the configuration parameters for queuing.
// This field may be non-empty only if `type` is `"Queue"`.
// +optional
Queuing *QueuingConfiguration
}

// LimitResponseType identifies how a Limited priority level handles a request that can not be executed right now
type LimitResponseType string

// Supported limit responses.
const (
// LimitResponseTypeQueue means that requests that can not be executed right now are queued until they can be executed or a queuing limit is hit
LimitResponseTypeQueue LimitResponseType = "Queue"

// LimitResponseTypeReject means that requests that can not be executed right now are rejected
LimitResponseTypeReject LimitResponseType = "Reject"
)

// QueuingConfiguration holds the configuration parameters for queuing
type QueuingConfiguration struct {
// `queues` is the number of queues for this priority level. The
// queues exist independently at each apiserver. The value must be
// positive. Setting it to 1 effectively precludes
Expand Down
10 changes: 6 additions & 4 deletions pkg/apis/flowcontrol/v1alpha1/defaults.go
Expand Up @@ -40,6 +40,12 @@ func SetDefaults_FlowSchemaSpec(spec *v1alpha1.FlowSchemaSpec) {
}
}

func SetDefaults_LimitedPriorityLevelConfiguration(lplc *v1alpha1.LimitedPriorityLevelConfiguration) {
if lplc.AssuredConcurrencyShares == 0 {
lplc.AssuredConcurrencyShares = PriorityLevelConfigurationDefaultAssuredConcurrencyShares
}
}

// SetDefaults_FlowSchema sets default values for flow schema
func SetDefaults_QueuingConfiguration(cfg *v1alpha1.QueuingConfiguration) {
if cfg.HandSize == 0 {
Expand All @@ -51,8 +57,4 @@ func SetDefaults_QueuingConfiguration(cfg *v1alpha1.QueuingConfiguration) {
if cfg.QueueLengthLimit == 0 {
cfg.QueueLengthLimit = PriorityLevelConfigurationDefaultQueueLengthLimit
}
if cfg.AssuredConcurrencyShares == 0 {
cfg.AssuredConcurrencyShares = PriorityLevelConfigurationDefaultAssuredConcurrencyShares
}

}

0 comments on commit f9bc2bc

Please sign in to comment.