Skip to content

[#435] fix: webhook taint conflict check incorrectly rejects dry-run rules - #436

Open
tejassinghbhati wants to merge 1 commit into
kubernetes-sigs:mainfrom
tejassinghbhati:fix/webhook-dryrun-taint-conflict-false-positive
Open

[#435] fix: webhook taint conflict check incorrectly rejects dry-run rules#436
tejassinghbhati wants to merge 1 commit into
kubernetes-sigs:mainfrom
tejassinghbhati:fix/webhook-dryrun-taint-conflict-false-positive

Conversation

@tejassinghbhati

@tejassinghbhati tejassinghbhati commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

The validation webhook blocks creation of a dryRun: true rule whenever an enforcement rule already manages the same taint key on overlapping nodes. Because dry-run rules never write taints to nodes, they cannot produce the concurrent-update conflict the guard is designed to prevent. The rejection is a false positive that makes the primary use case for dryRun, previewing the impact of a new rule against a taint key already in active use is impossible when the webhook is enabled.

Root cause

validateTaintConflicts iterates all existing rules and flags any pair sharing taint.key + taint.effect on overlapping selectors. It does not check spec.dryRun on either side, so it treats dry-run rules as if they were enforcement rules.

Fix

Add an early continue inside validateTaintConflicts when either the incoming or the existing rule has Spec.DryRun set:

// Dry-run rules never write taints, so they cannot produce a real // conflict regardless of taint key or selector overlap.
if rule.Spec.DryRun || existingRule.Spec.DryRun {
    continue
}

Tests

Two regression tests added to nodereadinessgaterule_webhook_test.go:

  1. A dryRun: true rule with the same taint key as an existing enforcement rule on overlapping nodes is accepted.
  2. An enforcement rule is accepted when a dryRun: true rule already exists for the same taint key on overlapping nodes.

go test ./internal/webhook/... — 41 passed, 0 failed.

Related issue

Fixes #435

Type of change

/kind bug

Checklist

  • go build ./... passes
  • go test ./internal/webhook/... passes (41 tests, no envtest required)

Does this PR introduce a user-facing change?

NONE

validateTaintConflicts blocked creation of a dryRun:true rule whenever
an enforcement rule already managed the same taint key on overlapping
nodes. A dry-run rule never writes taints to nodes, so it cannot produce
the concurrent-update conflict that the guard is designed to prevent.

The fix adds an early continue when either the incoming or the existing
rule has Spec.DryRun set, so the conflict check only applies to pairs
of enforcement rules.

Two regression tests are added: one confirms that a dry-run rule is
accepted when an enforcement rule holds the same taint key, and the
reverse, that an enforcement rule is accepted when a dry-run rule
already exists for that key.

Signed-off-by: Tejas Singh Bhati <tejassinghbhati077@gmail.com>
@kubernetes-prow kubernetes-prow Bot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 19, 2026
@netlify

netlify Bot commented Aug 19, 2026

Copy link
Copy Markdown

Deploy Preview for node-readiness-controller canceled.

Name Link
🔨 Latest commit 7ba9f0a
🔍 Latest deploy log https://app.netlify.com/projects/node-readiness-controller/deploys/6a860108b98fe40008a798e9

@kubernetes-prow
kubernetes-prow Bot requested a review from ajaysundark August 19, 2026 19:16
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: tejassinghbhati
Once this PR has been reviewed and has the lgtm label, please assign ajaysundark 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

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 19, 2026
@kubernetes-prow

Copy link
Copy Markdown

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

@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 19, 2026
@ajaysundark

Copy link
Copy Markdown
Contributor

Hi, thanks for raising the PR. I am not clear where this is needed. I asked a question on the issue #435 (comment), can we discuss this further before arriving at a fix?

@tejassinghbhati

Copy link
Copy Markdown
Contributor Author

Sounds good,
Actually I just replied on the issue with the use case and safety details, let's continue the discussion over there.

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.

[BUG] Webhook taint conflict check incorrectly rejects dry-run rules

2 participants