fix based on the suggestion

This commit is contained in:
Kensei Nakada
2023-03-05 15:01:34 +00:00
parent 33daba24fb
commit f76258f0ff
2 changed files with 13 additions and 15 deletions

View File

@@ -431,10 +431,9 @@ func (a *HorizontalController) computeReplicasForMetric(ctx context.Context, hpa
case autoscalingv2.ContainerResourceMetricSourceType:
if !a.containerResourceMetricsEnabled {
// If the container resource metrics feature is disabled but the object has the one,
// that means the user enabled the feature once, created some HPAs with the container resource metrics, and disabled it finally.
// We cannot return errors in this case because that'll result in all HPAs with the container resource metric sources failing to scale down.
// Thus, here we silently ignore it and return current replica values so that it won't affect the autoscaling decision
return specReplicas, "", time.Time{}, condition, nil
// that means the user enabled the feature once,
// created some HPAs with the container resource metrics, and disabled it finally.
return 0, "", time.Time{}, condition, fmt.Errorf("the container resource metrics feature is disabled by the feature gate")
}
replicaCountProposal, timestampProposal, metricNameProposal, condition, err = a.computeStatusForContainerResourceMetric(ctx, specReplicas, spec, hpa, selector, status)
if err != nil {