package request
import "k8s.io/apiserver/pkg/util/flowcontrol/request"
Index ¶
- Constants
- Variables
- type ListWorkEstimatorConfig
- type MutatingWorkEstimatorConfig
- type SeatSeconds
- func SeatsTimesDuration(seats float64, duration time.Duration) SeatSeconds
- func (ss SeatSeconds) DurationPerSeat(seats float64) time.Duration
- func (ss SeatSeconds) String() string
- func (ss SeatSeconds) ToFloat() float64
- type StorageObjectCountTracker
- type WorkEstimate
- type WorkEstimatorConfig
- type WorkEstimatorFunc
Constants ¶
const MaxSeatSeconds = SeatSeconds(math.MaxUint64)
MaxSeatsSeconds is the maximum representable value of SeatSeconds
const MinSeatSeconds = SeatSeconds(0)
MinSeatSeconds is the lowest representable value of SeatSeconds
Variables ¶
var ( // ObjectCountNotFoundErr is returned when the object count for // a given resource is not being tracked. ObjectCountNotFoundErr = errors.New("object count not found for the given resource") // ObjectCountStaleErr is returned when the object count for a // given resource has gone stale due to transient failures. ObjectCountStaleErr = errors.New("object count has gone stale for the given resource") )
Types ¶
type ListWorkEstimatorConfig ¶
type ListWorkEstimatorConfig struct { ObjectsPerSeat float64 `json:"objectsPerSeat,omitempty"` }
ListWorkEstimatorConfig holds work estimator parameters related to list requests.
type MutatingWorkEstimatorConfig ¶
type MutatingWorkEstimatorConfig struct { // TODO(wojtekt): Remove it once we tune the algorithm to not fail // scalability tests. Enabled bool `json:"enable,omitempty"` EventAdditionalDuration metav1.Duration `json:"eventAdditionalDurationMs,omitempty"` WatchesPerSeat float64 `json:"watchesPerSeat,omitempty"` }
MutatingWorkEstimatorConfig holds work estimator parameters related to watches of mutating objects.
type SeatSeconds ¶
type SeatSeconds uint64
SeatSeconds is a measure of work, in units of seat-seconds, using a fixed-point representation. `SeatSeconds(n)` represents `n/ssScale` seat-seconds. The `ssScale` constant is private to the implementation here, no other code should use it.
func SeatsTimesDuration ¶
func SeatsTimesDuration(seats float64, duration time.Duration) SeatSeconds
SeatsTimeDuration produces the SeatSeconds value for the given factors. This is intended only to produce small values, increments in work rather than amount of work done since process start.
func (SeatSeconds) DurationPerSeat ¶
func (ss SeatSeconds) DurationPerSeat(seats float64) time.Duration
DurationPerSeat returns duration per seat. This division may lose precision.
func (SeatSeconds) String ¶
func (ss SeatSeconds) String() string
String converts to a string. This is suitable for large as well as small values.
func (SeatSeconds) ToFloat ¶
func (ss SeatSeconds) ToFloat() float64
ToFloat converts to a floating-point representation. This conversion may lose precision.
type StorageObjectCountTracker ¶
type StorageObjectCountTracker interface { // Set is invoked to update the current number of total // objects for the given resource Set(string, int64) // Get returns the total number of objects for the given resource. // The following errors are returned: // - if the count has gone stale for a given resource due to transient // failures ObjectCountStaleErr is returned. // - if the given resource is not being tracked then // ObjectCountNotFoundErr is returned. Get(string) (int64, error) // RunUntil starts all the necessary maintenance. RunUntil(stopCh <-chan struct{}) }
StorageObjectCountTracker is an interface that is used to keep track of of the total number of objects for each resource. {group}.{resource} is used as the key name to update and retrieve the total number of objects for a given resource.
func NewStorageObjectCountTracker ¶
func NewStorageObjectCountTracker() StorageObjectCountTracker
NewStorageObjectCountTracker returns an instance of StorageObjectCountTracker interface that can be used to keep track of the total number of objects for each resource.
type WorkEstimate ¶
type WorkEstimate struct { // InitialSeats is the number of seats occupied while the server is // executing this request. InitialSeats uint64 // FinalSeats is the number of seats occupied at the end, // during the AdditionalLatency. FinalSeats uint64 // AdditionalLatency specifies the additional duration the seats allocated // to this request must be reserved after the given request had finished. // AdditionalLatency should not have any impact on the user experience, the // caller must not experience this additional latency. AdditionalLatency time.Duration }
WorkEstimate carries three of the four parameters that determine the work in a request. The fourth parameter is the duration of the initial phase of execution.
func (*WorkEstimate) MaxSeats ¶
func (we *WorkEstimate) MaxSeats() int
MaxSeats returns the maximum number of seats the request occupies over the phases of being served.
type WorkEstimatorConfig ¶
type WorkEstimatorConfig struct { *ListWorkEstimatorConfig `json:"listWorkEstimatorConfig,omitempty"` *MutatingWorkEstimatorConfig `json:"mutatingWorkEstimatorConfig,omitempty"` // MinimumSeats is the minimum number of seats a request must occupy. MinimumSeats uint64 `json:"minimumSeats,omitempty"` // MaximumSeatsLimit is an upper limit on the max seats a request can occupy. // // NOTE: work_estimate_seats_samples metric uses the value of maximumSeats // as the upper bound, so when we change maximumSeats we should also // update the buckets of the metric. MaximumSeatsLimit uint64 `json:"maximumSeatsLimit,omitempty"` }
WorkEstimatorConfig holds work estimator parameters.
func DefaultWorkEstimatorConfig ¶
func DefaultWorkEstimatorConfig() *WorkEstimatorConfig
DefaultWorkEstimatorConfig creates a new WorkEstimatorConfig with default values.
type WorkEstimatorFunc ¶
type WorkEstimatorFunc func(request *http.Request, flowSchemaName, priorityLevelName string) WorkEstimate
WorkEstimatorFunc returns the estimated work of a given request. This function will be used by the Priority & Fairness filter to estimate the work of incoming requests.
func NewWorkEstimator ¶
func NewWorkEstimator(objectCountFn objectCountGetterFunc, watchCountFn watchCountGetterFunc, config *WorkEstimatorConfig, maxSeatsFn maxSeatsFunc) WorkEstimatorFunc
NewWorkEstimator estimates the work that will be done by a given request, if no WorkEstimatorFunc matches the given request then the default work estimate of 1 seat is allocated to the request.
func (WorkEstimatorFunc) EstimateWork ¶
func (e WorkEstimatorFunc) EstimateWork(r *http.Request, flowSchemaName, priorityLevelName string) WorkEstimate
Source Files ¶
config.go list_work_estimator.go mutating_work_estimator.go object_count_tracker.go seat_seconds.go width.go
- Version
- v0.33.0 (latest)
- Published
- Apr 23, 2025
- Platform
- linux/amd64
- Imports
- 16 packages
- Last checked
- 7 hours ago –
Tools for package owners.