Skip to content

Commit c6d9c81

Browse files
committed
feat: add starting pods configuration to scaling behavior
- Introduced `StartingPods` configuration in the scaler CRD to manage how starting (not-ready) pods affect scale-up decisions. - Added properties: `bypassGateOnPanic`, `maxStartingPods`, `maxStartingPodPercent`, and `startingPodWeight` to control scaling behavior based on starting pods. - Updated `ScalingContext` interface and its implementation to include methods for retrieving starting pods configuration. - Enhanced scaling algorithms (BudScaler and KPA) to consider starting pods when calculating effective replicas and determining scale-up gating. - Implemented tests for effective replica calculations and scale-up gating logic based on starting pods. - Added utility functions to count starting pods in the autoscaler.
1 parent 47dd684 commit c6d9c81

10 files changed

Lines changed: 1440 additions & 343 deletions

File tree

api/scaler/v1alpha1/budaiscaler_types.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,39 @@ type ScalingPolicy struct {
455455
PeriodSeconds int32 `json:"periodSeconds"`
456456
}
457457

458+
// StartingPodsConfig configures how starting (not-ready) pods affect scaling decisions.
459+
// This helps prevent over-scaling when pods are slow to become ready.
460+
type StartingPodsConfig struct {
461+
// StartingPodWeight is the weight (0.0-1.0) to assign to starting pods
462+
// when calculating effective capacity.
463+
// 0.0 = ignore starting pods completely
464+
// 1.0 = count starting pods as fully ready
465+
// Default: 0.5 (count each starting pod as 50% capacity)
466+
// +optional
467+
StartingPodWeight *string `json:"startingPodWeight,omitempty"`
468+
469+
// MaxStartingPods is the maximum number of starting pods allowed before
470+
// gating further scale-up operations. Set to 0 to disable the gate.
471+
// Default: 0 (disabled)
472+
// +optional
473+
// +kubebuilder:validation:Minimum=0
474+
MaxStartingPods *int32 `json:"maxStartingPods,omitempty"`
475+
476+
// MaxStartingPodPercent is the maximum percentage of total pods that can
477+
// be in starting state before gating scale-up.
478+
// Set to 0 to disable. Default: 0 (disabled)
479+
// +optional
480+
// +kubebuilder:validation:Minimum=0
481+
// +kubebuilder:validation:Maximum=100
482+
MaxStartingPodPercent *int32 `json:"maxStartingPodPercent,omitempty"`
483+
484+
// BypassGateOnPanic allows scale-up even when gate is active if the
485+
// algorithm is in panic mode (metrics severely above threshold).
486+
// Default: false (important for LLM workloads with long cold starts)
487+
// +optional
488+
BypassGateOnPanic *bool `json:"bypassGateOnPanic,omitempty"`
489+
}
490+
458491
// ScalingRules defines rules for scaling in a particular direction.
459492
type ScalingRules struct {
460493
// StabilizationWindowSeconds is the number of seconds to look back
@@ -483,6 +516,12 @@ type ScalingRules struct {
483516
// For example, 0.1 means 10% fluctuation is tolerated.
484517
// +optional
485518
Tolerance *string `json:"tolerance,omitempty"`
519+
520+
// StartingPods configures how starting (not-ready) pods affect scale-up decisions.
521+
// This helps prevent over-scaling when pods have long startup times.
522+
// Only applicable for ScaleUp rules.
523+
// +optional
524+
StartingPods *StartingPodsConfig `json:"startingPods,omitempty"`
486525
}
487526

488527
// BudAIScalerStatus defines the observed state of BudAIScaler.

api/scaler/v1alpha1/zz_generated.deepcopy.go

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)