Skip to content
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

(TopologySpread) Evict pods with selectors that match multiple nodes #525

Merged

Conversation

damemi
Copy link
Contributor

@damemi damemi commented Mar 11, 2021

Fixes #524

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 11, 2021
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 11, 2021
Copy link
Contributor Author

@damemi damemi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: damemi, uthark

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -289,11 +289,11 @@ func balanceDomains(
// however we still account for it "being evicted" so the algorithm can complete
// TODO(@damemi): Since we don't order pods wrt their affinities, we should refactor this to skip the current pod
// but still try to get the required # of movePods (instead of just chopping that value off the slice above)
if aboveToEvict[k].Spec.NodeSelector != nil ||
Copy link
Contributor

@ingvagabund ingvagabund Mar 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you break the changes into two steps (in the same commit)?

  1. create isRequiredDuringSchedulingIgnoredDuringExecution = aboveToEvict[k].Spec.Affinity != nil && aboveToEvict[k].Spec.Affinity.NodeAffinity != nil && aboveToEvict[k].Spec.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution != nil variable so it's easier to read the condition
  2. fix the bug

In which case the change will look like:

aboveToEvict[k].Spec.NodeSelector != nil ||
(
	isRequiredDuringSchedulingIgnoredDuringExecution &&
	nodesPodFitsOnBesidesCurrent(aboveToEvict[k], nodeMap) == 0
)

-->

(
	aboveToEvict[k].Spec.NodeSelector != nil || isRequiredDuringSchedulingIgnoredDuringExecution
) &&
nodesPodFitsOnBesidesCurrent(aboveToEvict[k], nodeMap) == 0

After which it's clear why the change is required.

Copy link
Contributor

@ingvagabund ingvagabund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change to improve the readability

@damemi damemi force-pushed the topology-spread-selector-fix branch from 4da1862 to af26b57 Compare March 12, 2021 18:50
@damemi
Copy link
Contributor Author

damemi commented Mar 12, 2021

Thanks @ingvagabund, updated

@ingvagabund
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 14, 2021
@k8s-ci-robot k8s-ci-robot merged commit 39e5b34 into kubernetes-sigs:master Mar 14, 2021
briend pushed a commit to briend/descheduler that referenced this pull request Feb 11, 2022
…lector-fix

(TopologySpread) Evict pods with selectors that match multiple nodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Descheduler not evicting pods with node selectors
4 participants