Skip to content

webhook: detect matchExpression selector overlaps#246

Open
sahitya-chandra wants to merge 2 commits into
kubernetes-sigs:mainfrom
sahitya-chandra:fix/webhook-selector-overlap-expressions
Open

webhook: detect matchExpression selector overlaps#246
sahitya-chandra wants to merge 2 commits into
kubernetes-sigs:mainfrom
sahitya-chandra:fix/webhook-selector-overlap-expressions

Conversation

@sahitya-chandra
Copy link
Copy Markdown
Contributor

@sahitya-chandra sahitya-chandra commented May 13, 2026

Description

Port the selector-overlap helper downstream (for now) into the webhook package and use it from nodeSelectorsOverlap.

PR #212 fixed the common matchLabels subset case, but its implementation intentionally left a limitation for selectors using matchExpressions. This change replaces that heuristic with a local satisfiability check over selector requirements grouped by key, covering:

  • In, NotIn, Equals, DoubleEquals, and NotEquals
  • Exists and DoesNotExist
  • numeric GreaterThan and LessThan
  • non-subset matchLabels that still overlap on a possible node label set

Related Issue / PR

Follow-up to #212

Type of Change

/kind bug

Testing

  • make setup-envtest
  • env GOCACHE=/tmp/node-readiness-controller-go-cache make test

Checklist

  • Code follows the project style and is formatted with go fmt
  • Tests added for matchExpressions overlap and non-overlap cases
  • make test passes

Does this PR introduce a user-facing change?

Fixed webhook validation to detect overlapping NodeReadinessRule node selectors that use matchExpressions, preventing additional conflicting rules from being accepted.

Signed-off-by: Sahitya Chandra <sahityajb@gmail.com>
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label May 13, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 13, 2026

Deploy Preview for node-readiness-controller canceled.

Name Link
🔨 Latest commit 95cb376
🔍 Latest deploy log https://app.netlify.com/projects/node-readiness-controller/deploys/6a05777174e8e5000826dc85

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sahitya-chandra
Once this PR has been reviewed and has the lgtm label, please assign haircommander for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 13, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @sahitya-chandra. 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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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 added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 13, 2026
@sahitya-chandra sahitya-chandra marked this pull request as draft May 13, 2026 18:21
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 13, 2026
@sahitya-chandra sahitya-chandra marked this pull request as ready for review May 14, 2026 07:20
@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 14, 2026
@k8s-ci-robot k8s-ci-robot requested a review from ajaysundark May 14, 2026 07:21
@sahitya-chandra
Copy link
Copy Markdown
Contributor Author

/cc @ajaysundark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants