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

RemoveDuplicates: take node taints, node affinity and node selector into account when computing a number of feasible nodes for the average occurence of pods per node #563

Conversation

ingvagabund
Copy link
Contributor

@ingvagabund ingvagabund commented May 5, 2021

Nodes with taints which are not tolerated by evicted pods will never run the pods. The same holds for node affinity and node selector. So increase the number of pods per feasible nodes to decrease the number of evicted pods.

Fixes: #551

TODO:

  • take taints into account
  • take node selector into account

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 5, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ingvagabund

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 5, 2021
@ingvagabund ingvagabund force-pushed the removeduplicates-take-taints-into-account-for-node-count branch from e91aa16 to f29cc0b Compare May 9, 2021 16:10
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 9, 2021
@ingvagabund ingvagabund force-pushed the removeduplicates-take-taints-into-account-for-node-count branch from f29cc0b to e0e5b73 Compare May 9, 2021 16:26
@ingvagabund ingvagabund changed the title WIP: RemoveDuplicates: take node taints into account when computing a number of feasible nodes for the average occurence of pods per node RemoveDuplicates: take node taints, node affinity and node selector into account when computing a number of feasible nodes for the average occurence of pods per node May 9, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 9, 2021
Comment on lines +231 to +240
if utils.TolerationsEqual(pod.Spec.Tolerations, dp.Spec.Tolerations) &&
utils.NodeSelectorsEqual(getNodeAffinityNodeSelector(pod), getNodeAffinityNodeSelector(dp)) &&
reflect.DeepEqual(pod.Spec.NodeSelector, dp.Spec.NodeSelector) {
duplicated = true
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

will this count pods as duplicate if they don't have tolerations/selectors/affinity?

Copy link
Contributor

Choose a reason for hiding this comment

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

also could you explain a bit more about what this check is for? I am a little confused about the check for duplicate node selector rules here (not that it's wrong, it's likely just me 🙂 )

Copy link
Contributor Author

@ingvagabund ingvagabund May 18, 2021

Choose a reason for hiding this comment

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

The idea is to assign each pod a (tolerations, nodeselectors, node affinity) triple (including nil instances). Also, there's some logic that reduces duplicated tolerations/nodeselectors/nodeaffinities terms and sorts the terms so it's easy to identify the duplicated terms. So when two triples are equal, evaluation of both corresponding pods wrt. feasible nodes will end up the same. Thus, reducing the number of (pod, node) evaluations with the same result. Thus, minimizing the set of pods where we check how many nodes are feasible for them once evicted. getTargetNodes is computing how many nodes are feasible for all the pods there were marked for eviction. So the average number of pods per node can be adjusted based on what getTargetNodes returns.

The checks in getTargetNodes will be most probably all duplicates of checks in IsEvictable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see so this check is meant for efficiency in the later checks if I understand correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, efficiency purposes only.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's a great idea. Would you mind adding that to the comment for this block, to explain that this is for efficiency? It wasn't clear to me why we were looking for distinct pods at this point

Copy link
Contributor Author

@ingvagabund ingvagabund May 18, 2021

Choose a reason for hiding this comment

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

Done. Adding

// In order to reduce the number of pods processed, identify pods which have
// equal (tolerations, nodeselectors, node affinity) terms and considered them
// as identical. Identical pods wrt. (tolerations, nodeselectors, node affinity) terms
// will produce the same result when checking if a pod is feasible for a node.
// Thus, improving efficiency of processing pods marked for eviction.

…nto account when computing a number of feasible nodes for the average occurence of pods per node

Nodes with taints which are not tolerated by evicted pods will never run the
pods. The same holds for node affinity and node selector.
So increase the number of pods per feasible nodes to decrease the
number of evicted pods.
@ingvagabund ingvagabund force-pushed the removeduplicates-take-taints-into-account-for-node-count branch from e0e5b73 to 5396282 Compare May 18, 2021 14:13
@damemi
Copy link
Contributor

damemi commented May 21, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 21, 2021
@k8s-ci-robot k8s-ci-robot merged commit 3b9d3d9 into kubernetes-sigs:master May 21, 2021
@ingvagabund ingvagabund deleted the removeduplicates-take-taints-into-account-for-node-count branch May 21, 2021 12:39
briend pushed a commit to briend/descheduler that referenced this pull request Feb 11, 2022
…tes-take-taints-into-account-for-node-count

RemoveDuplicates: take node taints, node affinity and node selector into account when computing a number of feasible nodes for the average occurence of pods per node
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RemoveDuplicates: take taints and node selector into account when computing the number of duplicates
3 participants