Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

nutmos
Copy link
Contributor

@nutmos nutmos commented Sep 17, 2025

Description

This PR adds admission validation for the Alertmanager PagerdutyURL in global configuration.

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

Unit Tests

Changelog entry

- Add Alertmanager PagerdutyURL Global Config admission webhook validation

@nutmos nutmos changed the title Feat: add validation for Alertmanager PagerdutyURL in Global Config #7910 Feat: add validation for Alertmanager PagerdutyURL in Global Config Sep 19, 2025
@nutmos nutmos marked this pull request as ready for review September 19, 2025 08:52
@nutmos nutmos requested a review from a team as a code owner September 19, 2025 08:52
@simonpasquier
Copy link
Contributor

Thanks for doing this! Ideally we'd need end-to-end tests to make sure that it works as expected with the actual admission webhook deployed (similar to the testInvalidRulesAreRejected() test). We also need to update the configuration + doc of the admission webhook.

If you feel that it's over your knowledge, we can defer this to a follow-up PR. I'll test locally anyway.

@nutmos
Copy link
Contributor Author

nutmos commented Sep 19, 2025

@simonpasquier Let me try implementing first. I'll let you know if these items have to be deferred to the new PRs. Thank you for your suggestion!

@nutmos
Copy link
Contributor Author

nutmos commented Sep 20, 2025

@simonpasquier I updated E2E test and document already.

@simonpasquier
Copy link
Contributor

Sorry for the back-and-forth on this PR, my brain is slow to process apparently. Shouldn't we harden the validation of the pagerdutyUrl field and change the type from *string to *URL?

To give a bit more context, the use case for admission webhooks is to supplement validation which can't be implemented via kubebuilder markers and/or CEL. I'm not saying that we don't need an admission webhook service for Alertmanager CRD but I'd prefer to avoid maintaining it unless it's absolutely required :)

// pagerdutyUrl defines the default Pagerduty URL.
// +optional
PagerdutyURL *string `json:"pagerdutyUrl,omitempty"`

@nutmos
Copy link
Contributor Author

nutmos commented Sep 22, 2025

@simonpasquier I do agree. It makes more sense to use kube validation instead of maintaining the code in the webhook.

Let me close this PR and do what you suggest instead. Thank you!

@nutmos nutmos closed this Sep 22, 2025
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.

2 participants