Skip to content

Commit 18f10c1

Browse files
authored
Merge pull request #7997 from damikag/scale-down-slo-update-metric
Emit scale down metric even when there is no scale down candidates.
2 parents 75f90f2 + 49b271f commit 18f10c1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cluster-autoscaler/core/scaledown/status/status.go

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ const (
9898
ScaleDownInCooldown
9999
// ScaleDownInProgress - the scale down wasn't attempted, because a previous scale-down was still in progress.
100100
ScaleDownInProgress
101+
// ScaleDownNoCandidates - the scale down was skipped because of no scale down candidates.
102+
ScaleDownNoCandidates
101103
)
102104

103105
// NodeDeleteResultType denotes the type of the result of node deletion. It provides deeper

cluster-autoscaler/core/static_autoscaler.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) caerrors.AutoscalerErr
606606

607607
metrics.UpdateDurationFromStart(metrics.FindUnneeded, unneededStart)
608608

609-
scaleDownInCooldown := a.isScaleDownInCooldown(currentTime, scaleDownCandidates)
609+
scaleDownInCooldown := a.isScaleDownInCooldown(currentTime)
610610
klog.V(4).Infof("Scale down status: lastScaleUpTime=%s lastScaleDownDeleteTime=%v "+
611611
"lastScaleDownFailTime=%s scaleDownForbidden=%v scaleDownInCooldown=%v",
612612
a.lastScaleUpTime, a.lastScaleDownDeleteTime, a.lastScaleDownFailTime,
@@ -628,6 +628,11 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) caerrors.AutoscalerErr
628628
if scaleDownInCooldown {
629629
scaleDownStatus.Result = scaledownstatus.ScaleDownInCooldown
630630
a.updateSoftDeletionTaints(allNodes)
631+
} else if len(scaleDownCandidates) == 0 {
632+
klog.V(4).Infof("Starting scale down: no scale down candidates. skipping...")
633+
scaleDownStatus.Result = scaledownstatus.ScaleDownNoCandidates
634+
metrics.UpdateLastTime(metrics.ScaleDown, time.Now())
635+
a.updateSoftDeletionTaints(allNodes)
631636
} else {
632637
klog.V(4).Infof("Starting scale down")
633638

@@ -712,8 +717,8 @@ func (a *StaticAutoscaler) addUpcomingNodesToClusterSnapshot(upcomingCounts map[
712717
return nil
713718
}
714719

715-
func (a *StaticAutoscaler) isScaleDownInCooldown(currentTime time.Time, scaleDownCandidates []*apiv1.Node) bool {
716-
scaleDownInCooldown := a.processorCallbacks.disableScaleDownForLoop || len(scaleDownCandidates) == 0
720+
func (a *StaticAutoscaler) isScaleDownInCooldown(currentTime time.Time) bool {
721+
scaleDownInCooldown := a.processorCallbacks.disableScaleDownForLoop
717722

718723
if a.ScaleDownDelayTypeLocal {
719724
return scaleDownInCooldown

0 commit comments

Comments
 (0)