diff --git a/cluster-autoscaler/core/static_autoscaler.go b/cluster-autoscaler/core/static_autoscaler.go index d9c9fcf9b72b..772f2030e218 100644 --- a/cluster-autoscaler/core/static_autoscaler.go +++ b/cluster-autoscaler/core/static_autoscaler.go @@ -621,23 +621,27 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) caerrors.AutoscalerErr a.processorCallbacks.disableScaleDownForLoop, scaleDownInCooldown) metrics.UpdateScaleDownInCooldown(scaleDownInCooldown) + // We want to delete unneeded Node Groups only if here is no current delete + // in progress. + _, drained := scaleDownActuationStatus.DeletionsInProgress() + var removedNodeGroups []cloudprovider.NodeGroup + if len(drained) == 0 { + var err error + removedNodeGroups, err = a.processors.NodeGroupManager.RemoveUnneededNodeGroups(autoscalingContext) + if err != nil { + klog.Errorf("Error while removing unneeded node groups: %v", err) + } + scaleDownStatus.RemovedNodeGroups = removedNodeGroups + } + if scaleDownInCooldown { scaleDownStatus.Result = scaledownstatus.ScaleDownInCooldown + if len(removedNodeGroups) > 0 { + a.processors.ScaleDownStatusProcessor.Process(autoscalingContext, scaleDownStatus) + } } else { klog.V(4).Infof("Starting scale down") - // We want to delete unneeded Node Groups only if there was no recent scale up, - // and there is no current delete in progress and there was no recent errors. - _, drained := scaleDownActuationStatus.DeletionsInProgress() - var removedNodeGroups []cloudprovider.NodeGroup - if len(drained) == 0 { - var err error - removedNodeGroups, err = a.processors.NodeGroupManager.RemoveUnneededNodeGroups(autoscalingContext) - if err != nil { - klog.Errorf("Error while removing unneeded node groups: %v", err) - } - } - scaleDownStart := time.Now() metrics.UpdateLastTime(metrics.ScaleDown, scaleDownStart) empty, needDrain := a.scaleDownPlanner.NodesToDelete(currentTime)