-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Use ScaleDownSetProcessor.GetNodesToRemove in scale down planner to filter NodesToDelete. #5330
Conversation
@@ -117,21 +117,20 @@ func (n *Nodes) Drop(node string) { | |||
// RemovableAt returns all nodes that can be removed at a given time, divided | |||
// into empty and non-empty node lists, as well as a list of nodes that were | |||
// unneeded, but are not removable, annotated by reason. | |||
func (n *Nodes) RemovableAt(context *context.AutoscalingContext, ts time.Time, resourcesLeft resource.Limits, resourcesWithLimits []string, as scaledown.ActuationStatus) (empty, needDrain []*apiv1.Node, unremovable []*simulator.UnremovableNode) { | |||
func (n *Nodes) RemovableAt(context *context.AutoscalingContext, ts time.Time, resourcesLeft resource.Limits, resourcesWithLimits []string, as scaledown.ActuationStatus) (empty, needDrain []simulator.NodeToBeRemoved, unremovable []*simulator.UnremovableNode) { |
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.
Since you're already changing the function signature to return simulator.NodeToBeRemoved
, I think it makes sense to just put empty & non-empty on a single list and let the caller worry about splitting them.
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 don't have strong opinion on this, but both callers of this method require distinction between empty and non-empty nodes to remove. Does it make sense then to merge the lists into 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 this results in a slightly cleaner interface. Don't have a too strong opinion on this either though, so up to you.
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.
If there is no strong opinion here, I would leave it as is, given we need the distinction.
LGTM, putting on hold to give you a chance to consider my comment. Feel free to cancel hold if you disagree. /lgtm |
/hold cancel |
@@ -282,7 +282,10 @@ func (sd *ScaleDown) NodesToDelete(currentTime time.Time, pdbs []*policyv1.PodDi | |||
} | |||
|
|||
scaleDownResourcesLeft := sd.resourceLimitsFinder.LimitsLeft(sd.context, allNodes, resourceLimiter, currentTime) | |||
empty, nonEmpty, unremovable := sd.unneededNodes.RemovableAt(sd.context, currentTime, scaleDownResourcesLeft, resourceLimiter.GetResources(), sd.nodeDeletionTracker) | |||
emptyToRemove, nonEmpty, unremovable := sd.unneededNodes.RemovableAt(sd.context, currentTime, scaleDownResourcesLeft, resourceLimiter.GetResources(), sd.nodeDeletionTracker) | |||
for _, emptyNode := range emptyToRemove { |
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.
Do we need the empty
list? Isn't it only used to extract the name in the loop below? Couldn't we just do the same thing as with nonEmpty
?
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.
Actually it is also returned, so we do need that.
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 mean we're setting the variable here, but empty
isn't returned anywhere from this function, right? It's only used to create candidateNames
. Or am I reading things wrong?
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.
It is named return value, see line 257 :)
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.
discussed offline, removed empty
filter NodesToDelete.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: olagacek, towca 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 |
Which component this PR applies to?
cluster-autoscaler
What type of PR is this?
/kind feature
What this PR does / why we need it:
Allows filtering of scale down candidates in scale down planner.
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: