Skip to content

Commit

Permalink
Merge pull request #4932 from towca/jtuznik/act-fix-2
Browse files Browse the repository at this point in the history
CA: make legacy SD wrapper always return nodeDeleteResults
  • Loading branch information
k8s-ci-robot authored Jun 1, 2022
2 parents 067bf36 + 8754bed commit 6ef081c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cluster-autoscaler/core/scaledown/legacy/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,16 @@ func (p *ScaleDownWrapper) NodesToDelete(currentTime time.Time) (empty, needDrai
func (p *ScaleDownWrapper) StartDeletion(empty, needDrain []*apiv1.Node, currentTime time.Time) (*status.ScaleDownStatus, errors.AutoscalerError) {
// Done to preserve legacy behavior, see comment on NodesToDelete.
if p.lastNodesToDeleteErr != nil || p.lastNodesToDeleteResult != status.ScaleDownNodeDeleteStarted {
return &status.ScaleDownStatus{Result: p.lastNodesToDeleteResult}, p.lastNodesToDeleteErr
// When there is no need for scale-down, p.lastNodesToDeleteResult is set to ScaleDownNoUnneeded. We have to still report node delete
// results in this case, otherwise they wouldn't get reported until the next call to actuator.StartDeletion (i.e. until the next scale-down
// attempt).
// Run actuator.StartDeletion with no nodes just to grab the delete results.
origStatus, _ := p.actuator.StartDeletion(nil, nil, currentTime)
return &status.ScaleDownStatus{
Result: p.lastNodesToDeleteResult,
NodeDeleteResults: origStatus.NodeDeleteResults,
NodeDeleteResultsAsOf: origStatus.NodeDeleteResultsAsOf,
}, p.lastNodesToDeleteErr
}
return p.actuator.StartDeletion(empty, needDrain, currentTime)
}
Expand Down

0 comments on commit 6ef081c

Please sign in to comment.