From b75fbda0ed29f5ffa6efe61879f3f9509682bd49 Mon Sep 17 00:00:00 2001 From: Kushagra Date: Fri, 2 Sep 2022 04:35:10 +0000 Subject: [PATCH] requested changes --- pkg/controller/podautoscaler/replica_calculator.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/controller/podautoscaler/replica_calculator.go b/pkg/controller/podautoscaler/replica_calculator.go index fe86a8111f6..049aa61f31c 100644 --- a/pkg/controller/podautoscaler/replica_calculator.go +++ b/pkg/controller/podautoscaler/replica_calculator.go @@ -106,9 +106,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% (all) of the resource request - maxTargetUtilization := int64(max(100, int32(targetUtilization))) + // or the utilization target for targets higher than 100% + fallbackUtilization := int64(max(100, targetUtilization)) for podName := range missingPods { - metrics[podName] = metricsclient.PodMetric{Value: requests[podName] * maxTargetUtilization / 100} + metrics[podName] = metricsclient.PodMetric{Value: requests[podName] * fallbackUtilization / 100} } } else if usageRatio > 1.0 { // on a scale-up, treat missing pods as using 0% of the resource request @@ -209,7 +210,7 @@ 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% (all) of the resource request + // on a scale-down, treat missing pods as using exactly the target amount for podName := range missingPods { metrics[podName] = metricsclient.PodMetric{Value: targetUtilization} }