Skip to content

Commit 8174b95

Browse files
committed
Fix cool down status condition to trigger scale down
1 parent 0f4fea6 commit 8174b95

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

cluster-autoscaler/core/static_autoscaler.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) caerrors.AutoscalerErr
647647

648648
if scaleDownInCooldown {
649649
scaleDownStatus.Result = scaledownstatus.ScaleDownInCooldown
650+
a.updateSoftDeletionTaints(allNodes)
650651
} else {
651652
klog.V(4).Infof("Starting scale down")
652653

@@ -666,20 +667,7 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) caerrors.AutoscalerErr
666667
a.clusterStateRegistry.Recalculate()
667668
}
668669

669-
if (scaleDownStatus.Result == scaledownstatus.ScaleDownNoNodeDeleted ||
670-
scaleDownStatus.Result == scaledownstatus.ScaleDownNoUnneeded) &&
671-
a.AutoscalingContext.AutoscalingOptions.MaxBulkSoftTaintCount != 0 {
672-
taintableNodes := a.scaleDownPlanner.UnneededNodes()
673-
674-
// Make sure we are only cleaning taints from selected node groups.
675-
selectedNodes := filterNodesFromSelectedGroups(a.CloudProvider, allNodes...)
676-
677-
// This is a sanity check to make sure `taintableNodes` only includes
678-
// nodes from selected nodes.
679-
taintableNodes = intersectNodes(selectedNodes, taintableNodes)
680-
untaintableNodes := subtractNodes(selectedNodes, taintableNodes)
681-
actuation.UpdateSoftDeletionTaints(a.AutoscalingContext, taintableNodes, untaintableNodes)
682-
}
670+
a.updateSoftDeletionTaints(allNodes)
683671

684672
if typedErr != nil {
685673
klog.Errorf("Failed to scale down: %v", typedErr)
@@ -700,6 +688,21 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) caerrors.AutoscalerErr
700688
return nil
701689
}
702690

691+
func (a *StaticAutoscaler) updateSoftDeletionTaints(allNodes []*apiv1.Node) {
692+
if a.AutoscalingContext.AutoscalingOptions.MaxBulkSoftTaintCount != 0 {
693+
taintableNodes := a.scaleDownPlanner.UnneededNodes()
694+
695+
// Make sure we are only cleaning taints from selected node groups.
696+
selectedNodes := filterNodesFromSelectedGroups(a.CloudProvider, allNodes...)
697+
698+
// This is a sanity check to make sure `taintableNodes` only includes
699+
// nodes from selected nodes.
700+
taintableNodes = intersectNodes(selectedNodes, taintableNodes)
701+
untaintableNodes := subtractNodes(selectedNodes, taintableNodes)
702+
actuation.UpdateSoftDeletionTaints(a.AutoscalingContext, taintableNodes, untaintableNodes)
703+
}
704+
}
705+
703706
func (a *StaticAutoscaler) isScaleDownInCooldown(currentTime time.Time, scaleDownCandidates []*apiv1.Node) bool {
704707
scaleDownInCooldown := a.processorCallbacks.disableScaleDownForLoop || len(scaleDownCandidates) == 0
705708

0 commit comments

Comments
 (0)