kubernetes-sigs / descheduler

Descheduler for Kubernetes
https://sigs.k8s.io/descheduler
Apache License 2.0
4.23k stars 645 forks source link

Add argument to remove only pods violating allowlisted taints #1360

Closed etoster closed 3 months ago

etoster commented 3 months ago

Fixes #1353.

Adds the option to apply the RemovePodsViolatingNodeTaints strategy only for an explicitly allowlisted set of taints.

When a list of includedTaints is provided, a taint will be considered if and only if it matches an included key or key=value from the list. Otherwise it will be ignored. Leaving includedTaints unset will include any taint by default.

linux-foundation-easycla[bot] commented 3 months ago

CLA Signed

The committers listed above are authorized under a signed CLA.

k8s-ci-robot commented 3 months ago

Welcome @etoster!

It looks like this is your first PR to kubernetes-sigs/descheduler 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/descheduler has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. :smiley:

k8s-ci-robot commented 3 months ago

Hi @etoster. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
knelasevero commented 3 months ago

/ok-to-test

knelasevero commented 3 months ago

should we let users set both included and excluded taints? When we look at namespace inclusion/exclusion we make inclusion be something like: "this and nothing else". Shouldn't we keep consistency here?

@a7i @damemi @ingvagabund

damemi commented 3 months ago

should we let users set both included and excluded taints? When we look at namespace inclusion/exclusion we make inclusion be something like: "this and nothing else". Shouldn't we keep consistency here?

@a7i @damemi @ingvagabund

I'm for using one or the other until there's a use case for both. I had mentioned in the original issue that it didn't seem harmful to do both, but I agree that it's safer and more consistent to make them exclusive for now.

etoster commented 3 months ago

should we let users set both included and excluded taints? When we look at namespace inclusion/exclusion we make inclusion be something like: "this and nothing else". Shouldn't we keep consistency here?

@damemi also pointed this out in the issue.

I started looking into how it's done for namespaces, but I wasn't sure where would be the right place to check in this case. If it would be within the strategy plugin or if there is some linter parsing the deschedulerPolicy resource before (which I didn't find). So I proposed the change without it, but I'm happy to add it, if you could give me some guidance on what you consider the best practice for it!

ingvagabund commented 3 months ago

+1 for allowing to set only one of include/exclude lists, not both.

ingvagabund commented 3 months ago

If it would be within the strategy plugin

Yeap. Each strategy/plugin is responsible for its own arg validation. E.g. https://github.com/kubernetes-sigs/descheduler/blob/master/pkg/framework/plugins/removeduplicates/validation.go

etoster commented 3 months ago

Thanks @ingvagabund! I added the validation to allow only one of include/exclude taints. Please have a look. cc @knelasevero @damemi

knelasevero commented 3 months ago

After Jan's comments are addressed I think this lgtm

ingvagabund commented 3 months ago

/approve /lgtm

k8s-ci-robot commented 3 months ago

[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: - ~~[OWNERS](https://github.com/kubernetes-sigs/descheduler/blob/master/OWNERS)~~ [ingvagabund] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
etoster commented 3 months ago

Thank you all for your quick responses and helpful feedback! This was a great experience as a first time contributor. :)