-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkg/operator: create Select method for rule selection #5221
pkg/operator: create Select method for rule selection #5221
Conversation
This is not yet done for Thanos, still working on updating PR and removing duplicates hence moving to draft :) |
Removing draft for initial review |
f1ad186
to
9f21d50
Compare
9f21d50
to
001ddce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm 👍
Need to implement for Thanos as well. I will look in reducing duplicate code between Thanos and Prometheus |
001ddce
to
535734b
Compare
@simonpasquier Can you take another look at this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we factorize the 2 selectRules()
methods (probably in pkg/operator)?
71e6b7a
to
2761903
Compare
2761903
to
0c47b7e
Compare
@simonpasquier PTAL when you get a chance :) |
0c47b7e
to
9636cd0
Compare
I updated with changes suggested, need to remove a few units as well. Updating that as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few nits :)
d0c112f
to
df1eefe
Compare
@simonpasquier Addressed all comments except the nsLabeler (added comment in line) |
if !strings.Contains(content, "partial_response_strategy: warn") { | ||
t.Fatalf("expected `partial_response_strategy` to be set in PrometheusRule as `warn`") | ||
|
||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are tests moved from Prometheus package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet refactoring 👍 Great job JP!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm but you'll have to rebase on main :)
df1eefe
to
98a2f7f
Compare
@simonpasquier rebased |
I realize that we don't have an e2e test verifying that the operator doesn't select invalid rules now. As the validating webhook config watches for all namespaces, an invalid rule can never reach the operator. I'd suggest to tweak the
prometheus-operator/test/framework/resources/prometheus-operator-validatingwebhook.yaml Line 13 in cb272a6
Then a rule created in a namespace with the |
06ac5ac
to
7a66710
Compare
0af5c62
to
d522534
Compare
defer testCtx.Cleanup(t) | ||
ns := framework.CreateNamespace(context.Background(), t, testCtx) | ||
framework.SetupPrometheusRBAC(context.Background(), t, testCtx, ns) | ||
ruleFilesNamespaceSelector := map[string]string{"excludeFromWebhook": "true", "role": "rulefile"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note on labels added:
"role": "rulefile"
label is added here so that operator selects the rule created for evaulation. We use this label in ruleSelector
in framework.MakeBasicPrometheus()
as well as framework..MakeBasicRule()
"excludeFromWebhook": "true"
is added to skip webhook validation and validate if operator doesn't fail reconcilation due to invalid rule
@simonpasquier Rebased and updated the e2e test to check prometheus reconciliation status after invalid rule created |
d522534
to
dd18cc4
Compare
Just for more validation I tested this change manually as well checked the e2e test against main branch on which refactoring is not there. Prometheus fails to reconcile without this change. Also the metric |
@simonpasquier Can you take another look at this one, updated test :) |
reorganized rule selection code from prometheus and thanos package to reduce duplicate code. This change will also make sure there is no reconcillation failure on controller when a bad PrometheusRule object is created. Instead of a reconcillation failure, controller will just reject the bad PrometheusRule. Fixes prometheus-operator#5191 Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
dd18cc4
to
aa92da4
Compare
Thanks! |
Fixes #5191
Signed-off-by: Jayapriya Pai slashpai9@gmail.com
Description
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
If it fixes a bug or resolves a feature request, be sure to link to that issue.
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.)Changelog entry
Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.