Skip to content

Conversation

@slashpai
Copy link
Contributor

@slashpai slashpai commented Sep 16, 2025

Description

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.

If it fixes an existing issue (bug or feature), use the following keyword:

When label selector fields like serviceMonitorSelector/serviceMonitorNamespaceSelector
contain invalid label keys/values (>63 chars or invalid characters),
reconciliation would fail.

This change adds validation before selector processing to gracefully handle
invalid selectors and provide clear error messages.

Fixes: #7915

Type of change

What type of changes does your code introduce to the Prometheus operator? Put an x in the box that apply.

  • CHANGE (fix or feature that would cause existing functionality to not work as expected)
  • FEATURE (non-breaking change which adds functionality)
  • BUGFIX (non-breaking change which fixes an issue)
  • ENHANCEMENT (non-breaking change which improves existing functionality)
  • NONE (if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)

Verification

Please check the Prometheus-Operator testing guidelines for recommendations about automated tests.

Changelog entry

Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.

CHANGE/BUGFIX: validate serviceMonitor selector labels to prevent reconciliation failures

@slashpai slashpai marked this pull request as ready for review October 8, 2025 07:56
@slashpai slashpai requested a review from a team as a code owner October 8, 2025 07:56
@slashpai slashpai changed the title fix: add cel validation for label selectors feat: validate serviceMonitor selector labels to prevent reconciliation failures Oct 8, 2025
@slashpai slashpai force-pushed the label-validate branch 4 times, most recently from 517c5ec to 9a0de5c Compare October 8, 2025 08:48
@slashpai slashpai requested a review from simonpasquier October 8, 2025 08:49
Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

should we create our own type (copied from metav1.LabelSelector) to avoid repeating the validation markers?

@slashpai
Copy link
Contributor Author

slashpai commented Oct 9, 2025

should we create our own type (copied from metav1.LabelSelector) to avoid repeating the validation markers?

yes working on it

…lures

When label selector fields like serviceMonitorSelector/serviceMonitorNamespaceSelector
contain invalid label keys/values (>63 chars or invalid characters),
reconciliation would fail.

This change adds validation before selector processing to gracefully handle
invalid selectors and provide clear error messages.

Fixes: prometheus-operator#7915

Assisted-by: Cursor
Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
@slashpai slashpai changed the title feat: validate serviceMonitor selector labels to prevent reconciliation failures CHANGE/BUGFIX: validate label selectors to prevent reconciliation failures Oct 9, 2025
@slashpai
Copy link
Contributor Author

slashpai commented Oct 9, 2025

I will work on rebase once we are ok with changes.

@simonpasquier can you review

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Label selectors aren't checked for max label name length

2 participants