Skip to content

Commit

Permalink
Merge pull request kubernetes#5901 from olagacek/master
Browse files Browse the repository at this point in the history
Remove unneeded node groups regardless of scale down being in cooldown.
  • Loading branch information
k8s-ci-robot authored Jul 4, 2023
2 parents 3c32e77 + 72c0a7e commit adb16c8
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions cluster-autoscaler/core/static_autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit adb16c8

Please sign in to comment.