-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 error to create service metrics when run operator-sdk up local #2190
fix error to create service metrics when run operator-sdk up local #2190
Conversation
I'm confused about the motivation for this. As far as I can tell, we already skip metrics service creation during
Is this just about improving the log messages? |
Hi @joelanford, We do not skip actually. We just throw the error which makes the users thinking that something is wrong so the idea here is to keep as it is done for the leader and make clear that it was not created and why instead of throw errors. See:
|
HMO: Technically is a very simple change. It is a nit as you can see :-) But very helpful to not cause misunderstanding and improve the user experience. I mean, since the info does not clearly show a bug in the user point of view. |
@camilamacedo86: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
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.
thanks! I was a bit confused by this error message 😄
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
// Add the Metrics Service | ||
addMetrics(ctx, cfg, namespace) |
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.
It looks like addMetrics()
is a small wrapper around serveCRMetrics()
that does some extra logging and error handling, right?
IMO, another function in the main.go
template for this is a bit much, and I think we could add the extra error handling in line in the body of the main
function.
If I understand correctly, it seems like this PR could be reduced to:
if err = serveCRMetrics(cfg); err != nil {
- log.Info("Could not generate and serve custom resource metrics", "error", err.Error())
+ if errors.Is(err, k8sutil.ErrRunLocal) {
+ log.Info("Skipping CR metrics server creation; not running in a cluster.")
+ } else {
+ log.Info("Could not generate and serve custom resource metrics", "error", err.Error())
+ }
}
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.
The logs/msgs came from more than one point in the original code (See serveCRMetrics, CreateMetricsService, CreateServiceMonitors). The idea was centralized/encapsulate the logic to add the metrics and do its improvement.
{"level":"info","ts":1563485392.3758454,"logger":"cmd","msg":"Could not generate and serve custom resource metrics","error":"operator run mode forced to local"}
{"level":"info","ts":1563485392.4013908,"logger":"cmd","msg":"Could not create metrics Service","error":"failed to initialize service object for metrics: OPERATOR_NAME must be set"}
{"level":"info","ts":1563485392.4066937,"logger":"cmd","msg":"Could not create ServiceMonitor object","error":"no ServiceMonitor registered with the API"}
In this way, just the above suggestion still not attending the expectations.
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.
Ah I see now. The diff was confusing me :)
CHANGELOG.md
Outdated
@@ -17,6 +17,7 @@ | |||
|
|||
### Bug Fixes | |||
|
|||
- Skip metrics creation when running the operator locally. ([#2190](https://github.com/operator-framework/operator-sdk/pull/2190)) |
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.
We already skip metrics creation when running locally, right? This PR is about logging a more informative message to help the user understand that skipping metrics creation is not an error, right?
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.
The current msgs/loggings give an impression that it is an error when is not.
I improved the description and move to changed section in the changelog.
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
This code was generated as part of the scaffold when using the sdk. This code was intended to mitigate a user error observed when using "operator-sdk up local" cmd. See operator-framework/operator-sdk#2190 for more information. We do not longer need this code. The metrics endpoint for prometheus is initialized by controller-runtime in the background. Signed-off-by: Matthias Diester <matthias.diester@de.ibm.com>
This code was generated as part of the scaffold when using the sdk. This code was intended to mitigate a user error observed when using "operator-sdk up local" cmd. See operator-framework/operator-sdk#2190 for more information. We do not longer need this code. The metrics endpoint for prometheus is initialized by controller-runtime in the background. Signed-off-by: Matthias Diester <matthias.diester@de.ibm.com>
This code was generated as part of the scaffold when using the sdk. This code was intended to mitigate a user error observed when using "operator-sdk up local" cmd. See operator-framework/operator-sdk#2190 for more information. We do not longer need this code. The metrics endpoint for prometheus is initialized by controller-runtime in the background. Signed-off-by: Matthias Diester <matthias.diester@de.ibm.com>
This code was generated as part of the scaffold when using the sdk. This code was intended to mitigate a user error observed when using "operator-sdk up local" cmd. See operator-framework/operator-sdk#2190 for more information. We do not longer need this code. The metrics endpoint for prometheus is initialized by controller-runtime in the background. Signed-off-by: Matthias Diester <matthias.diester@de.ibm.com>
This code was generated as part of the scaffold when using the sdk. This code was intended to mitigate a user error observed when using "operator-sdk up local" cmd. See operator-framework/operator-sdk#2190 for more information. We do not longer need this code. The metrics endpoint for prometheus is initialized by controller-runtime in the background. Signed-off-by: Matthias Diester <matthias.diester@de.ibm.com>
Description of the change:
Skip service metrics when is running out o the cluster
Motivation for the change:
Closes: #1702
LOCAL TEST
