From 755098cc316fc8b0f0064742226924c37f383570 Mon Sep 17 00:00:00 2001 From: j2gg0s Date: Thu, 9 Jun 2022 23:26:07 +0800 Subject: [PATCH] hpa: rename rebalanceIgnored to scaleUpWithUnready for understanding --- pkg/controller/podautoscaler/replica_calculator.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/controller/podautoscaler/replica_calculator.go b/pkg/controller/podautoscaler/replica_calculator.go index 6ca90c9f8ff..32ce877a345 100644 --- a/pkg/controller/podautoscaler/replica_calculator.go +++ b/pkg/controller/podautoscaler/replica_calculator.go @@ -94,8 +94,8 @@ func (c *ReplicaCalculator) GetResourceReplicas(ctx context.Context, currentRepl return 0, 0, 0, time.Time{}, err } - rebalanceIgnored := len(unreadyPods) > 0 && usageRatio > 1.0 - if !rebalanceIgnored && len(missingPods) == 0 { + scaleUpWithUnready := len(unreadyPods) > 0 && usageRatio > 1.0 + if !scaleUpWithUnready && len(missingPods) == 0 { if math.Abs(1.0-usageRatio) <= c.tolerance { // return the current replicas if the change would be too small return currentReplicas, utilization, rawUtilization, timestamp, nil @@ -119,7 +119,7 @@ func (c *ReplicaCalculator) GetResourceReplicas(ctx context.Context, currentRepl } } - if rebalanceIgnored { + if scaleUpWithUnready { // on a scale-up, treat unready pods as using 0% of the resource request for podName := range unreadyPods { metrics[podName] = metricsclient.PodMetric{Value: 0} @@ -196,9 +196,9 @@ func (c *ReplicaCalculator) calcPlainMetricReplicas(metrics metricsclient.PodMet usageRatio, utilization := metricsclient.GetMetricUtilizationRatio(metrics, targetUtilization) - rebalanceIgnored := len(unreadyPods) > 0 && usageRatio > 1.0 + scaleUpWithUnready := len(unreadyPods) > 0 && usageRatio > 1.0 - if !rebalanceIgnored && len(missingPods) == 0 { + if !scaleUpWithUnready && len(missingPods) == 0 { if math.Abs(1.0-usageRatio) <= c.tolerance { // return the current replicas if the change would be too small return currentReplicas, utilization, nil @@ -222,7 +222,7 @@ func (c *ReplicaCalculator) calcPlainMetricReplicas(metrics metricsclient.PodMet } } - if rebalanceIgnored { + if scaleUpWithUnready { // on a scale-up, treat unready pods as using 0% of the resource request for podName := range unreadyPods { metrics[podName] = metricsclient.PodMetric{Value: 0}