fix(webhook): check probes and scrapeconfigs RBAC only when CRDs exist#5011
Draft
u-kai wants to merge 2 commits into
Draft
fix(webhook): check probes and scrapeconfigs RBAC only when CRDs exist#5011u-kai wants to merge 2 commits into
u-kai wants to merge 2 commits into
Conversation
(open-telemetry#4456) Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
Contributor
|
Rather than doing this in the webhook, detecting these should be a part of the autodetect package. Right now we store a PrometheusCRAvailable boolean value in the config, whereas it should be a list of the available CRDs. Then the webhook would just pull it from the config. This may require some refactoring along the way. |
Signed-off-by: u-kai <76635578+u-kai@users.noreply.github.com>
Author
|
@swiatekm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
The webhook RBAC check for PrometheusCR only warned about
servicemonitorsandpodmonitors,missing
probesandscrapeconfigs.Also, warnings were emitted even when prometheus-operator was not installed in the cluster.
This fix dynamically discovers which
monitoring.coreos.comCRDs exist in the cluster via thediscovery API, and only includes those in the RBAC check.
Clusters without prometheus-operator installed will no longer receive false-positive warnings.
Link to tracking Issue(s):
Testing:
Updated unit tests in
targetallocator_webhook_test.goandcollector_webhook_test.goto cover the new dynamic CRD discovery behavior, including a case where no prometheus-operator CRDs are installed (zero warnings expected).Documentation: