address feedback: pass HPAScaleToZero option when already in use

This commit is contained in:
yongruilin
2026-02-13 22:50:16 +00:00
parent c9c926a96c
commit 8dd711ea80

View File

@@ -115,7 +115,8 @@ func (autoscalerStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.O
opts := validationOptionsForHorizontalPodAutoscaler(newHPA, oldHPA)
errs := validation.ValidateHorizontalPodAutoscalerUpdate(newHPA, oldHPA, opts)
var options []string
if utilfeature.DefaultFeatureGate.Enabled(features.HPAScaleToZero) {
oldHasZeroMinReplicas := oldHPA.Spec.MinReplicas != nil && *oldHPA.Spec.MinReplicas == 0
if utilfeature.DefaultFeatureGate.Enabled(features.HPAScaleToZero) || oldHasZeroMinReplicas {
options = append(options, "HPAScaleToZero")
}
return rest.ValidateDeclarativelyWithMigrationChecks(ctx, legacyscheme.Scheme, newHPA, oldHPA, errs, operation.Update, rest.WithOptions(options))