Skip to content
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

Merged

Conversation

saifshaikh48
Copy link
Contributor

@saifshaikh48 saifshaikh48 commented Mar 14, 2023

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

@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 14, 2023
@openshift-ci-robot
Copy link

@saifshaikh48: This pull request references Jira Issue OCPBUGS-10222, which is invalid:

  • expected the bug to target the "4.14.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

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

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.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 14, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 14, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@saifshaikh48
Copy link
Contributor Author

/jira refresh

@openshift-ci-robot
Copy link

@saifshaikh48: This pull request references Jira Issue OCPBUGS-10222, which is invalid:

  • expected the bug to target the "4.14.0" version, but it targets "4.14" instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/jira refresh

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
Copy link
Contributor Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 14, 2023
@openshift-ci-robot
Copy link

@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
  • bug is open, matching expected state (open)
  • bug target version (4.14.0) matches configured target version for branch (4.14.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @rrasouli

In response to this:

/jira refresh

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.

@openshift-ci openshift-ci bot requested a review from rrasouli March 14, 2023 19:31
@@ -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" {
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

@alinaryan
Copy link
Contributor

Thanks for taking this on!
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 14, 2023
@@ -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" {
Copy link
Contributor

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.

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Mar 14, 2023
@saifshaikh48 saifshaikh48 force-pushed the case-monitoring-label branch 2 times, most recently from d423559 to 8a3c4e3 Compare March 14, 2023 22:23
Copy link
Contributor

@aravindhp aravindhp left a 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?

pkg/metrics/metrics.go Outdated Show resolved Hide resolved
@saifshaikh48
Copy link
Contributor Author

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

if wmcoNamespace.Labels["openshift.io/cluster-monitoring"] != "true" {
metricsEnabled = false

boolVal := false
Copy link
Member

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.

Copy link
Contributor Author

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?

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 15, 2023

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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.
@mansikulkarni96
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 15, 2023
@mansikulkarni96
Copy link
Member

Fixes #1478

@openshift-ci-robot
Copy link

@saifshaikh48: This pull request references Jira Issue OCPBUGS-10222, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.14.0) matches configured target version for branch (4.14.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @rrasouli

In response to this:

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

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 saifshaikh48 marked this pull request as ready for review March 15, 2023 17:21
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 15, 2023
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 9216f3d and 2 for PR HEAD 767f93c in total

// 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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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

@saifshaikh48
Copy link
Contributor Author

/retest-required

cluster spinup flakes

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 16, 2023

@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.

@openshift-merge-robot openshift-merge-robot merged commit 6273896 into openshift:master Mar 16, 2023
@openshift-ci-robot
Copy link

@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:

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

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
Copy link
Contributor Author

saifshaikh48 commented Mar 16, 2023

/cherry-pick release-4.13

@openshift-cherrypick-robot

@saifshaikh48: new pull request created: #1494

In response to this:

/cherry-pick release-4.13
/cherry-pick release-4.12
/cherry-pick release-4.11
/cherry-pick release-4.10

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
Copy link
Contributor Author

saifshaikh48 commented Mar 16, 2023

/cherry-pick release-4.12

@openshift-cherrypick-robot

@saifshaikh48: new pull request created: #1495

In response to this:

/cherry-pick release-4.12

/cherry-pick release-4.11

/cherry-pick release-4.10

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
Copy link
Contributor Author

/cherry-pick release-4.11

@saifshaikh48
Copy link
Contributor Author

/cherry-pick release-4.10

@openshift-cherrypick-robot

@saifshaikh48: new pull request created: #1496

In response to this:

/cherry-pick release-4.11

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.

@openshift-cherrypick-robot

@saifshaikh48: new pull request created: #1497

In response to this:

/cherry-pick release-4.10

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.

@aravindhp
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
8 participants