diff --git a/pkg/controller/podautoscaler/replica_calculator.go b/pkg/controller/podautoscaler/replica_calculator.go index b065fce3743..c97c5f51140 100644 --- a/pkg/controller/podautoscaler/replica_calculator.go +++ b/pkg/controller/podautoscaler/replica_calculator.go @@ -105,9 +105,10 @@ func (c *ReplicaCalculator) GetResourceReplicas(ctx context.Context, currentRepl if len(missingPods) > 0 { if usageRatio < 1.0 { - // on a scale-down, treat missing pods as using 100% of the resource request + // on a scale-down, treat missing pods as using 100% (all) of the resource request + maxTargetUtilization := int64(max(100, int32(targetUtilization))) for podName := range missingPods { - metrics[podName] = metricsclient.PodMetric{Value: requests[podName]} + metrics[podName] = metricsclient.PodMetric{Value: requests[podName] * maxTargetUtilization / 100} } } else if usageRatio > 1.0 { // on a scale-up, treat missing pods as using 0% of the resource request @@ -208,9 +209,10 @@ func (c *ReplicaCalculator) calcPlainMetricReplicas(metrics metricsclient.PodMet if len(missingPods) > 0 { if usageRatio < 1.0 { - // on a scale-down, treat missing pods as using 100% of the resource request + // on a scale-down, treat missing pods as using 100% (all) of the resource request + maxTargetUtilization := int64(max(100, int32(targetUtilization))) for podName := range missingPods { - metrics[podName] = metricsclient.PodMetric{Value: targetUtilization} + metrics[podName] = metricsclient.PodMetric{Value: maxTargetUtilization} } } else { // on a scale-up, treat missing pods as using 0% of the resource request