-
Notifications
You must be signed in to change notification settings - Fork 66
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
OCPBUGS-10222: [metrics] Ignore case of cluster monitoring label #1479
OCPBUGS-10222: [metrics] Ignore case of cluster monitoring label #1479
Conversation
@saifshaikh48: This pull request references Jira Issue OCPBUGS-10222, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
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. |
Skipping CI for Draft Pull Request. |
/jira refresh |
@saifshaikh48: This pull request references Jira Issue OCPBUGS-10222, which is invalid:
Comment In response to this:
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. |
/jira refresh |
@saifshaikh48: This pull request references Jira Issue OCPBUGS-10222, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
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. |
pkg/metrics/metrics.go
Outdated
@@ -253,7 +254,7 @@ func (c *Config) validate(ctx context.Context) (bool, error) { | |||
if err != nil { | |||
return false, errors.Wrap(err, "error getting operator namespace") | |||
} | |||
if wmcoNamespace.Labels["openshift.io/cluster-monitoring"] != "true" { | |||
if strings.ToLower(wmcoNamespace.Labels["openshift.io/cluster-monitoring"]) != "true" { |
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.
So this will accept strings like tRue
etc. Do we want to do that or throw an 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.
Should be fine IMO. I don't see a reason to accept True
but not tRue
etc
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.
Thinking more about this, I suggest we rather do strconv.ParseBool.
Thanks for taking this on! |
pkg/metrics/metrics.go
Outdated
@@ -253,7 +254,7 @@ func (c *Config) validate(ctx context.Context) (bool, error) { | |||
if err != nil { | |||
return false, errors.Wrap(err, "error getting operator namespace") | |||
} | |||
if wmcoNamespace.Labels["openshift.io/cluster-monitoring"] != "true" { | |||
if strings.ToLower(wmcoNamespace.Labels["openshift.io/cluster-monitoring"]) != "true" { |
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.
Thinking more about this, I suggest we rather do strconv.ParseBool.
6605bcf
to
3de259e
Compare
d423559
to
8a3c4e3
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.
It also makes WMCO able to react to a change in the namespace's cluster monitoring label.
How does that happen? Don't we have to restart the operator?
You're right, I read the metrics code path wrong. I'll drop that from the commit msg |
8a3c4e3
to
d80c060
Compare
pkg/metrics/metrics.go
Outdated
if wmcoNamespace.Labels["openshift.io/cluster-monitoring"] != "true" { | ||
metricsEnabled = false | ||
|
||
boolVal := false |
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.
Instead of bool val, can we give it a monitoring specific name?
Maybe you can just use the metricsEnabled var 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.
I opted for the non-specific name because there's already a global variable by the name of metricsEnabled
(which gets assigned to the boolVal
later in this function). I can make this labelValue
instead?
d80c060
to
12d3fb5
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aravindhp, saifshaikh48 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This commit makes check for the monitoring label on the WMCO namespace accept all valid string representations of booleans to provide better user experience. Previously, not adhering to an all lowercase `true` value would result in WMCO ignoring the label and not configuring Prometheus metrics for Windows nodes.
e099d6f
to
767f93c
Compare
/lgtm |
Fixes #1478 |
@saifshaikh48: This pull request references Jira Issue OCPBUGS-10222, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
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. |
// validate will verify if cluster monitoring is enabled in the operator namespace. | ||
// If the label is not present, it will log and send warning events to the user. | ||
// validate will verify if cluster monitoring is enabled in the operator namespace. If the label is set to false or not | ||
// present, it will log and send warning events to the user. If the label holds a non-boolean value, returns an error. | ||
func (c *Config) validate(ctx context.Context) (bool, 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.
Does it make sense to add a unit test to cover the mentioned cases?
"testing" |
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.
I don't think it's necessary to add one since there's e2e tests covering this functionality
/retest-required cluster spinup flakes |
@saifshaikh48: all tests passed! Full PR test history. Your PR dashboard. 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. |
@saifshaikh48: Jira Issue OCPBUGS-10222: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-10222 has been moved to the MODIFIED state. In response to this:
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. |
/cherry-pick release-4.13 |
@saifshaikh48: new pull request created: #1494 In response to this:
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. |
/cherry-pick release-4.12 |
@saifshaikh48: new pull request created: #1495 In response to this:
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. |
/cherry-pick release-4.11 |
/cherry-pick release-4.10 |
@saifshaikh48: new pull request created: #1496 In response to this:
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. |
@saifshaikh48: new pull request created: #1497 In response to this:
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. |
@saifshaikh48 for bugs please do not cherry-pick to all releases from the master PR. Just to the release-4.n-1 branch. Then do the release-4.n-2 cherry pick from the release-4.n-1PR. If you don't do this then you have to manually fix up all the Jira links. So please close all the other cherry picks. |
This PR makes the cluster monitoring label for the WMCO namespace case insensitive to provide better user experience. Previously, not adhering to an all lowercase
true
value would result in WMCO ignoring the label and not configuring/exposing Prometheus metrics for Windows nodes.Fixes OCPBUGS-10222
Fixes #1478