-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Fix cool down status condition to trigger scale down #7954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cool down status condition to trigger scale down #7954
Conversation
|
Hi @abdelrahman882. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
26d3d3e to
a114cf0
Compare
| metrics.UpdateDurationFromStart(metrics.FindUnneeded, unneededStart) | ||
|
|
||
| scaleDownInCooldown := a.isScaleDownInCooldown(currentTime, scaleDownCandidates) | ||
| scaleDownInCooldown := a.isScaleDownInCooldown(currentTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think instead of changing this logic we should move the taint cleanup from the nesting it is currently in. The following blok should be executed regardless of if scale-down is in cooldown or what is the scaleDownStatus:
if a.AutoscalingContext.AutoscalingOptions.MaxBulkSoftTaintCount != 0 {
taintableNodes := a.scaleDownPlanner.UnneededNodes()
// Make sure we are only cleaning taints from selected node groups.
selectedNodes := filterNodesFromSelectedGroups(a.CloudProvider, allNodes...)
// This is a sanity check to make sure `taintableNodes` only includes
// nodes from selected nodes.
taintableNodes = intersectNodes(selectedNodes, taintableNodes)
untaintableNodes := subtractNodes(selectedNodes, taintableNodes)
actuation.UpdateSoftDeletionTaints(a.AutoscalingContext, taintableNodes, untaintableNodes)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, but UpdateSoftDeletionTaints this way will lead to the following:
- we might add soft taints to nodes even though scale down is in cool down (actuation.UpdateSoftDeletionTaints is cleaning up soft taints from needed nodes and adding those to unneeded nodes)
- we will execute this update regardless there is a node deletion or not (I am mentioning that because current implementation we update only if
scaleDownStatus.Result == scaledownstatus.ScaleDownNoNodeDeleted)
I don't see any big risk for the 2 points except for marking nodes with soft taints while scale down is in cool down which kinda not expected behaviour.
one suggestion would be to split actuation.UpdateSoftDeletionTaints to cleanUpSoftDeletionTaints and markSoftDeletionTaints and do the cleanup regardless and the marking just in scaledown
I updated the fix with your suggestion, please let me know if you want to consider the mentioned one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think like the current solution should be good enough:
- If scale-down is in cool down, we still want to persist the candidate (if there are any) taints and remove the non-candidate taints. This way we ensure that once cool down ends we will have the same cluster state as during the last run.
- I don't believe this is an issue. Honestly, I am surprised that this check (no deletion) was in place. I suspect this is a relict of the times when scale-down was not parallel, so it did not make sense to add annotations if we were supposed to spend the loop deleting some node.
@x13n, could you take a look as well? From my side it LGTM, but I would love to have additional pair of eyes on this change.
a114cf0 to
89b9a0c
Compare
89b9a0c to
2bbe859
Compare
| actuation.UpdateSoftDeletionTaints(a.AutoscalingContext, taintableNodes, untaintableNodes) | ||
| } | ||
|
|
||
| a.updateSoftDeletionTaints(allNodes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just call update soft deletion taints before the if scaleDownInCooldown, this way we won't have to call it in 2 different places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In runOnce we do the following order in
updateClusterStateupdates the nodes filtering out those withtoBeDeletedtaint- scale down and taint nodes with
toBeDeleted - add soft taints
DeletionCandidateto unneeded nodes ignoring those with hard tainttoBeDeleted
If we put that update before if scaleDownInCooldown we might add soft taints DeletionCandidate for the nodes that will scale down in the same loop just before scaling down and adding the hard taint toBeDeleted which I believe is fine and doesn't have any issues that i am aware of.
waiting for @x13n review and will update with the suggestion if there is no objection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep the existing order honestly. The reason is that soft tainting is not instant and it is better to start actuation as soon as CA makes up its mind on removing rather than to wait & increase risk of race conditions with scheduler. If you want to call the function just once, it can be done by putting this whole if cooldown { ... } else { ... } block into yet another function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, LGTM then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How confident are we that this made any actionable difference? The fact that (1) existing UT passed without any changes and (2) no new UT scenarios were added maybe suggests this had no effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simple test could be:
- starting RunOnce() at min count w/ some tainted nodes,
- asserting we go into cool down
- asserting that the taints are released
As far as I can tell, we currently do not have any unit tests that exercise ScaleDownInCooldown status?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @BigDarkClown, should we do a follow up work stream to add UT cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good point, @abdelrahman882 can you add unit tests in a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, will add those tomorrow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @rakechill mentioned, this code path was not covered in unit tests.
Added #7995, @jackfrancis The unit test there covers this case and it would fail in case we don't call updateSoftDeletionTaints in case of scaleDownInCooldown is true which should address you concerns.
cc: @x13n
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: abdelrahman882, BigDarkClown The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/cherry-pick cluster-autoscaler-release-1.32 |
|
@jackfrancis: new pull request created: #8098 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/cherry-pick cluster-autoscaler-release-1.31 |
|
@jackfrancis: #7954 failed to apply on top of branch "cluster-autoscaler-release-1.31": In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
CA sets soft taint
DeletionCandidateOfClusterAutoscalerbefore proceeding to scale down by some time, if during this time the nodes with these taints are excluded from being a candidates and length of scale down candidates became 0 then scale-down enters cool down and never executesUpdateSoftDeletionTaintsthat removes these unneeded taints.