-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Introduce API changes and fetaure gate CPU startup boost #8417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: experimental-cpu-boost
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,9 +163,16 @@ func ValidateVPA(vpa *vpa_types.VerticalPodAutoscaler, isCreate bool) error { | |
return fmt.Errorf("controlledValues shouldn't be specified if container scaling mode is off") | ||
} | ||
} | ||
if err := validateStartupBoost(policy.StartupBoost, isCreate); err != nil { | ||
return fmt.Errorf("invalid startupBoost in container %s: %v", policy.ContainerName, err) | ||
} | ||
} | ||
} | ||
|
||
if err := validateStartupBoost(vpa.Spec.StartupBoost, isCreate); err != nil { | ||
return fmt.Errorf("invalid startupBoost: %v", err) | ||
} | ||
|
||
if isCreate && vpa.Spec.TargetRef == nil { | ||
return fmt.Errorf("targetRef is required. If you're using v1beta1 version of the API, please migrate to v1") | ||
} | ||
|
@@ -177,6 +184,48 @@ func ValidateVPA(vpa *vpa_types.VerticalPodAutoscaler, isCreate bool) error { | |
return nil | ||
} | ||
|
||
func validateStartupBoost(startupBoost *vpa_types.StartupBoost, isCreate bool) error { | ||
if startupBoost == nil { | ||
return nil | ||
} | ||
|
||
if !features.Enabled(features.CPUStartupBoost) && isCreate { | ||
return fmt.Errorf("in order to use startupBoost, you must enable feature gate %s in the admission-controller args", features.CPUStartupBoost) | ||
} | ||
|
||
cpuBoost := startupBoost.CPU | ||
if cpuBoost == nil { | ||
return nil | ||
} | ||
boostType := cpuBoost.Type | ||
if boostType == nil { | ||
// Default to Factor when type is not specified. | ||
defaultType := vpa_types.FactorStartupBoostType | ||
boostType = &defaultType | ||
} | ||
Comment on lines
+201
to
+205
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that in the API type is marked as required, I'm wondering if that is incorrect? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Made the API field optional with default value of Factor. |
||
|
||
if *boostType != vpa_types.FactorStartupBoostType && *boostType != vpa_types.QuantityStartupBoostType { | ||
return fmt.Errorf("unexpected StartupBoost.CPU.Type value %s", *boostType) | ||
} | ||
|
||
if *boostType == vpa_types.FactorStartupBoostType { | ||
if cpuBoost.Factor == nil { | ||
return fmt.Errorf("StartupBoost.CPU.Factor is required when Type is Factor") | ||
} | ||
if *cpuBoost.Factor < 1 { | ||
return fmt.Errorf("invalid StartupBoost.CPU.Factor: must be >= 1 for Type Factor") | ||
} | ||
} else if *boostType == vpa_types.QuantityStartupBoostType { | ||
if cpuBoost.Quantity == nil { | ||
return fmt.Errorf("StartupBoost.CPU.Quantity is required when Type is Quantity") | ||
} | ||
if err := validateCPUResolution(*cpuBoost.Quantity); err != nil { | ||
return fmt.Errorf("invalid StartupBoost.CPU.Quantity: %v", err) | ||
} | ||
} | ||
return nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about checking if both Factor and Quantity are set at the same time? (So we ensure only one of them is set at a time) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome, I missed that! Thanks @omerap12 |
||
} | ||
|
||
func validateResourceResolution(name corev1.ResourceName, val apires.Quantity) error { | ||
switch name { | ||
case corev1.ResourceCPU: | ||
|
Uh oh!
There was an error while loading. Please reload this page.