Skip to content

webhook: nodeSelectorsOverlap only detects identical selectors, missing partial overlaps #211

@Shreya2005-2005

Description

@Shreya2005-2005

Describe the bug

In internal/webhook/nodereadinessgaterule_webhook.go, the
nodeSelectorsOverlap function uses string equality to detect overlapping
node selectors:

return sel1.String() == sel2.String()

This means two rules with different but overlapping selectors
(e.g. env=prod and env=prod,region=us) are not detected as
conflicting, even though both rules would match nodes labeled
env=prod,region=us and apply the same taint — causing conflicts.

Steps to reproduce

  1. Create rule A with nodeSelector env=prod
  2. Create rule B with nodeSelector env=prod,region=us and same taint key
  3. Webhook allows both rules despite overlapping selectors
  4. Both rules apply to nodes matching env=prod,region=us

Expected behavior

Webhook should detect partial selector overlaps and reject conflicting rules.

Actual behavior

Only identical selectors are detected. Partial overlaps are missed.

File

internal/webhook/nodereadinessgaterule_webhook.go line 127

Are you able to fix this issue?

Yes (I will propose a PR)

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions