From 62f29d23af75cabba243dc2b989c838fda9dd275 Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Tue, 15 Nov 2022 13:21:29 -0800 Subject: [PATCH] cluster-autoscaler: refactor BalanceScaleUpBetweenGroups --- .../processors/nodegroupset/balancing_processor.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cluster-autoscaler/processors/nodegroupset/balancing_processor.go b/cluster-autoscaler/processors/nodegroupset/balancing_processor.go index 9dd3906de87e..c65cb10ea214 100644 --- a/cluster-autoscaler/processors/nodegroupset/balancing_processor.go +++ b/cluster-autoscaler/processors/nodegroupset/balancing_processor.go @@ -97,15 +97,16 @@ func (b *BalancingNodeGroupSetProcessor) BalanceScaleUpBetweenGroups(context *co // group already maxed, ignore it continue } - info := ScaleUpInfo{ + if maxSize > currentSize { + // we still have capacity to expand + totalCapacity += (maxSize - currentSize) + } + scaleUpInfos = append(scaleUpInfos, ScaleUpInfo{ Group: ng, CurrentSize: currentSize, NewSize: currentSize, - MaxSize: maxSize} - scaleUpInfos = append(scaleUpInfos, info) - if maxSize-currentSize > 0 { - totalCapacity += maxSize - currentSize - } + MaxSize: maxSize, + }) } if totalCapacity < newNodes { klog.V(2).Infof("Requested scale-up (%v) exceeds node group set capacity, capping to %v", newNodes, totalCapacity)