-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Introduce API changes and feature 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
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,42 @@ 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 | ||
|
|
||
| switch boostType { | ||
| case 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") | ||
| } | ||
| case 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) | ||
| } | ||
| default: | ||
| return fmt.Errorf("unexpected StartupBoost.CPU.Type value %s", boostType) | ||
| } | ||
| return nil | ||
|
Contributor
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)
Member
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.
Contributor
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.