Skip to content

chore(defaultevictor): add MatchExpressions compatibility to the namespaceselector#1853

Merged
k8s-ci-robot merged 1 commit into
kubernetes-sigs:masterfrom
Fankhauserli:master
May 18, 2026
Merged

chore(defaultevictor): add MatchExpressions compatibility to the namespaceselector#1853
k8s-ci-robot merged 1 commit into
kubernetes-sigs:masterfrom
Fankhauserli:master

Conversation

@Fankhauserli
Copy link
Copy Markdown
Contributor

Description

We noticed that the new NamespaceLabelSelector does not implement the MatchExpressions selector. This is vital for our workflow, as we need to use an exclusion label with a MatchExpression.

Our target configuration looks something like this:

matchExpressions: 
  - key: "deschedulerExclusion"
    operator: "NotIn"
    values: ["true"]

Currently, the descheduler only checks for MatchLabels:

if ev.args.NamespaceLabelSelector == nil || len(ev.args.NamespaceLabelSelector.MatchLabels) == 0 {}

This Pull Request updates the condition to account for MatchExpressions as well, and adds the corresponding tests to ensure the new behavior works as expected.

if ev.args.NamespaceLabelSelector != nil && (len(ev.args.NamespaceLabelSelector.MatchLabels) > 0 || len(ev.args.NamespaceLabelSelector.MatchExpressions) > 0) {}

Checklist

Please ensure your pull request meets the following criteria before submitting
for review, these items will be used by reviewers to assess the quality and
completeness of your changes:

  • Code Readability: Is the code easy to understand, well-structured, and consistent with project conventions?
  • Naming Conventions: Are variable, function, and structs descriptive and consistent?
  • Code Duplication: Is there any repeated code that should be refactored?
  • Function/Method Size: Are functions/methods short and focused on a single task?
  • Comments & Documentation: Are comments clear, useful, and not excessive? Were comments updated where necessary?
  • Error Handling: Are errors handled appropriately ?
  • Testing: Are there sufficient unit/integration tests?
  • Performance: Are there any obvious performance issues or unnecessary computations?
  • Dependencies: Are new dependencies justified ?
  • Logging & Monitoring: Is logging used appropriately (not too verbose, not too silent)?
  • Backward Compatibility: Does this change break any existing functionality or APIs?
  • Resource Management: Are resources (files, connections, memory) managed and released properly?
  • PR Description: Is the PR description clear, providing enough context and explaining the motivation for the change?
  • Documentation & Changelog: Are README and docs updated if necessary?

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Mar 19, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @Fankhauserli!

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. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 19, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @Fankhauserli. 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.

Details

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.

@k8s-ci-robot k8s-ci-robot requested review from JaneLiuL and damemi March 19, 2026 09:15
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 19, 2026
@a7i
Copy link
Copy Markdown
Contributor

a7i commented Mar 25, 2026

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 25, 2026
@a7i
Copy link
Copy Markdown
Contributor

a7i commented Apr 8, 2026

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 8, 2026
@a7i a7i added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Apr 8, 2026
})

fakeClient := fake.NewClientset(node, nsProd, nsBackend, nsTest, podInProd, podInBackend, podInTest)
fakeClient := fake.NewSimpleClientset(node, nsProd, nsBackend, nsTest, podInProd, podInBackend, podInTest)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this intentional? The newly written tests use NewSimpleClientset.


fakeClient := fake.NewClientset(node, nsProd, nsTest, podInProd, podInTest)
sharedInformerFactory := informers.NewSharedInformerFactory(fakeClient, 0)
getPodAssignedToNode, _ := podutil.BuildGetPodsAssignedToNodeFunc(sharedInformerFactory.Core().V1().Pods().Informer())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably rare to fail here but still good practice to check the error

testCases := []struct {
name string
args *DefaultEvictorArgs
results map[string]bool // pod name -> should pass PreEvictionFilter
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about to create a list of pointers to pods to pass and not pass to make the selection more explicit instead of constructing it at the end? To make the test easier to read.

nsNoLabels.Labels = map[string]string{}

podInProd := test.BuildTestPod("pod-in-prod", 100, 100, node.Name, func(pod *v1.Pod) {
pod.Namespace = "ns-prod"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pod.Namespace = nsProd.Name to avoid duplicating the string literal. The same for other occurences.

nsNoLabels := test.BuildTestNamespace("ns-nolabels")
nsNoLabels.Labels = map[string]string{}

podInProd := test.BuildTestPod("pod-in-prod", 100, 100, node.Name, func(pod *v1.Pod) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

s/podInProd/podInProdFrontend to make it explicit. The same for other occurences.

defer cancel()
node := test.BuildTestNode("node1", 1000, 2000, 10, nil)

podProd := test.BuildTestPod("pod-prod", 100, 100, node.Name, func(pod *v1.Pod) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto. s/podProd/podProdFrontend and other occurences

testCases := []struct {
name string
args *DefaultEvictorArgs
results map[string]bool // pod name -> should pass Filter
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

@ingvagabund
Copy link
Copy Markdown
Contributor

ingvagabund commented May 11, 2026

The first commit introduces a lot of test code that is then removed/updated in the second commit. Can you please either squash the commits or make the new tests part of a single commit?

@ingvagabund
Copy link
Copy Markdown
Contributor

@Fankhauserli thank you for the code changes and welcome as a contributor

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 18, 2026
@ingvagabund
Copy link
Copy Markdown
Contributor

/approve
/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 18, 2026
@k8s-ci-robot
Copy link
Copy Markdown
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

Details 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 18, 2026
@k8s-ci-robot k8s-ci-robot merged commit 6b5f6b4 into kubernetes-sigs:master May 18, 2026
8 checks passed
eleboucher pushed a commit to eleboucher/homelab that referenced this pull request May 20, 2026
…escheduler (0.35.1 ➔ 0.36.0) (#586)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ghcr.io/home-operations/charts-mirror/descheduler](https://github.com/kubernetes-sigs/descheduler) | minor | `0.35.1` → `0.36.0` |

---

### Release Notes

<details>
<summary>kubernetes-sigs/descheduler (ghcr.io/home-operations/charts-mirror/descheduler)</summary>

### [`v0.36.0`](https://github.com/kubernetes-sigs/descheduler/releases/tag/v0.36.0): Descheduler v0.36.0

[Compare Source](kubernetes-sigs/descheduler@v0.35.1...v0.36.0)

#### What's Changed

- fix(ci): pin helm-unittest plugin version and bump chart-testing-action by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1834](kubernetes-sigs/descheduler#1834)
- Update helm RBAC to account for pvc failure on 0.35.0 by [@&#8203;cayla](https://github.com/cayla) in [#&#8203;1836](kubernetes-sigs/descheduler#1836)
- Add init containers support to Helm chart by [@&#8203;kamleshjoshi8102](https://github.com/kamleshjoshi8102) in [#&#8203;1826](kubernetes-sigs/descheduler#1826)
- Change icon URL in Chart.yaml by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1838](kubernetes-sigs/descheduler#1838)
- fix: resolve detected data races by [@&#8203;ingvagabund](https://github.com/ingvagabund) in [#&#8203;1842](kubernetes-sigs/descheduler#1842)
- fix(ci): upgrade codeql-action to v4 and clean up security workflow by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1847](kubernetes-sigs/descheduler#1847)
- update golang semconv dependencies by [@&#8203;sammedsingalkar09](https://github.com/sammedsingalkar09) in [#&#8203;1848](kubernetes-sigs/descheduler#1848)
- Extend PodLifeTime with condition, exit code, owner kind, and transition time filters by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1844](kubernetes-sigs/descheduler#1844)
- security: Update trivy-action to use sha for v0.35.0 by [@&#8203;Priyankasaggu11929](https://github.com/Priyankasaggu11929) in [#&#8203;1854](kubernetes-sigs/descheduler#1854)
- security: upgrade grpc and otel sdk dependencies by [@&#8203;sammedsingalkar09](https://github.com/sammedsingalkar09) in [#&#8203;1859](kubernetes-sigs/descheduler#1859)
- evictions: fix missing observability for background evictions by [@&#8203;tiraboschi](https://github.com/tiraboschi) in [#&#8203;1856](kubernetes-sigs/descheduler#1856)
- fix(descheduler): reset prometheus usage client at each extension point by [@&#8203;tiraboschi](https://github.com/tiraboschi) in [#&#8203;1862](kubernetes-sigs/descheduler#1862)
- fix(.github/workflows/manifests.yaml): pin actions to a sha by [@&#8203;ingvagabund](https://github.com/ingvagabund) in [#&#8203;1868](kubernetes-sigs/descheduler#1868)
- cloudbuild: pin gcb-docker-gcloud image by digest by [@&#8203;Paramesh324](https://github.com/Paramesh324) in [#&#8203;1871](kubernetes-sigs/descheduler#1871)
- chart: allow overriding ServiceMonitor apiVersion by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1837](kubernetes-sigs/descheduler#1837)
- ci: pin GitHub Actions to immutable SHAs by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1875](kubernetes-sigs/descheduler#1875)
- evictions: fix assumePod silently dropping success metric on informer race by [@&#8203;tiraboschi](https://github.com/tiraboschi) in [#&#8203;1873](kubernetes-sigs/descheduler#1873)
- chore(defaultevictor): add MatchExpressions compatibility to the namespaceselector by [@&#8203;Fankhauserli](https://github.com/Fankhauserli) in [#&#8203;1853](kubernetes-sigs/descheduler#1853)
- fix(test/setupTestSandbox): wait until initial objects are propagated to informers by [@&#8203;ingvagabund](https://github.com/ingvagabund) in [#&#8203;1878](kubernetes-sigs/descheduler#1878)
- \[v0.36.0] release prep: bump k8s/go deps, manifests, docs, and CI matrix by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1874](kubernetes-sigs/descheduler#1874)

#### New Contributors

- [@&#8203;kamleshjoshi8102](https://github.com/kamleshjoshi8102) made their first contribution in [#&#8203;1826](kubernetes-sigs/descheduler#1826)
- [@&#8203;Priyankasaggu11929](https://github.com/Priyankasaggu11929) made their first contribution in [#&#8203;1854](kubernetes-sigs/descheduler#1854)
- [@&#8203;Paramesh324](https://github.com/Paramesh324) made their first contribution in [#&#8203;1871](kubernetes-sigs/descheduler#1871)
- [@&#8203;Fankhauserli](https://github.com/Fankhauserli) made their first contribution in [#&#8203;1853](kubernetes-sigs/descheduler#1853)

**Full Changelog**: <kubernetes-sigs/descheduler@v0.35.0...v0.36.0>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL21pbm9yIl19-->

Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/586
doonga pushed a commit to greyrock-labs/home-ops that referenced this pull request May 20, 2026
…uler ( 0.35.1 ➔ 0.36.0 ) (#85)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ghcr.io/home-operations/charts-mirror/descheduler](https://github.com/kubernetes-sigs/descheduler) | minor | `0.35.1` → `0.36.0` |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/34) for more information.

---

### Release Notes

<details>
<summary>kubernetes-sigs/descheduler (ghcr.io/home-operations/charts-mirror/descheduler)</summary>

### [`v0.36.0`](https://github.com/kubernetes-sigs/descheduler/releases/tag/v0.36.0): Descheduler v0.36.0

[Compare Source](kubernetes-sigs/descheduler@v0.35.1...v0.36.0)

#### What's Changed

- fix(ci): pin helm-unittest plugin version and bump chart-testing-action by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1834](kubernetes-sigs/descheduler#1834)
- Update helm RBAC to account for pvc failure on 0.35.0 by [@&#8203;cayla](https://github.com/cayla) in [#&#8203;1836](kubernetes-sigs/descheduler#1836)
- Add init containers support to Helm chart by [@&#8203;kamleshjoshi8102](https://github.com/kamleshjoshi8102) in [#&#8203;1826](kubernetes-sigs/descheduler#1826)
- Change icon URL in Chart.yaml by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1838](kubernetes-sigs/descheduler#1838)
- fix: resolve detected data races by [@&#8203;ingvagabund](https://github.com/ingvagabund) in [#&#8203;1842](kubernetes-sigs/descheduler#1842)
- fix(ci): upgrade codeql-action to v4 and clean up security workflow by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1847](kubernetes-sigs/descheduler#1847)
- update golang semconv dependencies by [@&#8203;sammedsingalkar09](https://github.com/sammedsingalkar09) in [#&#8203;1848](kubernetes-sigs/descheduler#1848)
- Extend PodLifeTime with condition, exit code, owner kind, and transition time filters by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1844](kubernetes-sigs/descheduler#1844)
- security: Update trivy-action to use sha for v0.35.0 by [@&#8203;Priyankasaggu11929](https://github.com/Priyankasaggu11929) in [#&#8203;1854](kubernetes-sigs/descheduler#1854)
- security: upgrade grpc and otel sdk dependencies by [@&#8203;sammedsingalkar09](https://github.com/sammedsingalkar09) in [#&#8203;1859](kubernetes-sigs/descheduler#1859)
- evictions: fix missing observability for background evictions by [@&#8203;tiraboschi](https://github.com/tiraboschi) in [#&#8203;1856](kubernetes-sigs/descheduler#1856)
- fix(descheduler): reset prometheus usage client at each extension point by [@&#8203;tiraboschi](https://github.com/tiraboschi) in [#&#8203;1862](kubernetes-sigs/descheduler#1862)
- fix(.github/workflows/manifests.yaml): pin actions to a sha by [@&#8203;ingvagabund](https://github.com/ingvagabund) in [#&#8203;1868](kubernetes-sigs/descheduler#1868)
- cloudbuild: pin gcb-docker-gcloud image by digest by [@&#8203;Paramesh324](https://github.com/Paramesh324) in [#&#8203;1871](kubernetes-sigs/descheduler#1871)
- chart: allow overriding ServiceMonitor apiVersion by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1837](kubernetes-sigs/descheduler#1837)
- ci: pin GitHub Actions to immutable SHAs by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1875](kubernetes-sigs/descheduler#1875)
- evictions: fix assumePod silently dropping success metric on informer race by [@&#8203;tiraboschi](https://github.com/tiraboschi) in [#&#8203;1873](kubernetes-sigs/descheduler#1873)
- chore(defaultevictor): add MatchExpressions compatibility to the namespaceselector by [@&#8203;Fankhauserli](https://github.com/Fankhauserli) in [#&#8203;1853](kubernetes-sigs/descheduler#1853)
- fix(test/setupTestSandbox): wait until initial objects are propagated to informers by [@&#8203;ingvagabund](https://github.com/ingvagabund) in [#&#8203;1878](kubernetes-sigs/descheduler#1878)
- \[v0.36.0] release prep: bump k8s/go deps, manifests, docs, and CI matrix by [@&#8203;a7i](https://github.com/a7i) in [#&#8203;1874](kubernetes-sigs/descheduler#1874)

#### New Contributors

- [@&#8203;kamleshjoshi8102](https://github.com/kamleshjoshi8102) made their first contribution in [#&#8203;1826](kubernetes-sigs/descheduler#1826)
- [@&#8203;Priyankasaggu11929](https://github.com/Priyankasaggu11929) made their first contribution in [#&#8203;1854](kubernetes-sigs/descheduler#1854)
- [@&#8203;Paramesh324](https://github.com/Paramesh324) made their first contribution in [#&#8203;1871](kubernetes-sigs/descheduler#1871)
- [@&#8203;Fankhauserli](https://github.com/Fankhauserli) made their first contribution in [#&#8203;1853](kubernetes-sigs/descheduler#1853)

**Full Changelog**: <kubernetes-sigs/descheduler@v0.35.0...v0.36.0>

</details>

---

### Configuration

📅 **Schedule**: (in timezone America/New_York)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xODIuMiIsInVwZGF0ZWRJblZlciI6IjQzLjE4Mi4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL21pbm9yIl19-->

Reviewed-on: https://git.greyrock.io/greyrock-labs/home-ops/pulls/85
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants