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
fix: Add validation method for controller and crd's #5476
fix: Add validation method for controller and crd's #5476
Conversation
c3be907
to
ba459cc
Compare
28bc095
to
5118fee
Compare
We won't be able to move suggestions? |
@simonpasquier Can you review when you get chance? |
5118fee
to
38693c9
Compare
Making a few changes hence moving to draft |
b15d356
to
7b442fa
Compare
@@ -282,25 +281,6 @@ func New(ctx context.Context, conf operator.Config, logger log.Logger, r prometh | |||
|
|||
// Run the controller. | |||
func (c *Operator) Run(ctx context.Context) error { | |||
crdInstalled, err := k8sutil.IsAPIGroupVersionResourceSupported(c.kclient.Discovery(), monitoringv1alpha1.SchemeGroupVersion.String(), monitoringv1alpha1.PrometheusAgentName) |
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.
Moved to k8sutil.CheckPrerequisites()
@@ -1332,44 +1312,3 @@ func (c *Operator) handleMonitorNamespaceUpdate(oldo, curo interface{}) { | |||
) | |||
} | |||
} | |||
|
|||
// getMissingPermissions returns the RBAC permissions that the controller would need to be |
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.
Moved to k8sutil
7b442fa
to
49bf8bc
Compare
49bf8bc
to
cec6ea3
Compare
@simonpasquier @JoaoBraveCoding This should be good to review again :) |
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.
Brilliant :)
Just a nit
37f73c8
to
da926b9
Compare
Addressed comments and few more fixes :) |
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.
Looks great! Just some small comments
d6cfa5f
to
a033063
Compare
@JoaoBraveCoding @simonpasquier are we good with the changes? :) |
3087946
to
91a52d6
Compare
31cb711
to
5086dfa
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.
One small nit but lgtm!
method `CheckPrerequisites()` to avoid creating controller object incase of validation failure. This is used for prometheus-agent controller as part of this commit. These methods can be re-used for future CRD validation and controllers Signed-off-by: Jayapriya Pai <slashpai9@gmail.com>
5086dfa
to
096c4c2
Compare
@simonpasquier updated 🤞🏻 |
thanks! |
How can I add permission to prometheus agent CRD ? I installed using helm. |
The necessary permissions can be seen here. I'm not really familiar how to do so using helm. Maybe it's worth asking at the helm repository? |
Move controller creation pre-requisites to validation method
CheckPrerequisites()
to avoid creatingcontroller object incase of validation failure. This is used for prometheus-agent controller as part of
this commit. These methods can be re-used for future CRD validation
and controllers
This change is result of alert fired during e2e test for prometheus-operator version upgrade in ocp openshift#223.
PrometheusOperatorNotReady
was fired forprometheus-agent
controller since CRD was not installed. Same alert will fire for upstream users who doesn't install prometheus-agent crd. This commit creates agent controller object only when validations are met.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.