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-45027: No Events Generated after changing cluster-monitoring Label #2605

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mansikulkarni96
Copy link
Member

This commit fixes the controller to generate events when the cluster-monitoring label is not present or removed from the operator namespace.

@openshift-ci-robot openshift-ci-robot added the jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. label Jan 9, 2025
Copy link
Contributor

openshift-ci bot commented Jan 9, 2025

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

@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 Jan 9, 2025
@openshift-ci-robot openshift-ci-robot added 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 Jan 9, 2025
@openshift-ci-robot
Copy link

@mansikulkarni96: This pull request references Jira Issue OCPBUGS-45027, which is invalid:

  • expected the bug to target the "4.19.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 commit fixes the controller to generate events when the cluster-monitoring label is not present or removed from the operator namespace.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 9, 2025
@mansikulkarni96
Copy link
Member Author

/approve cancel

@mansikulkarni96
Copy link
Member Author

/test aws-e2e-operator

@openshift-ci openshift-ci bot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 9, 2025
Copy link
Contributor

openshift-ci bot commented Jan 10, 2025

@mansikulkarni96: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/aws-e2e-operator 269583c link true /test aws-e2e-operator

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-sigs/prow repository. I understand the commands that are listed here.

Copy link
Contributor

@jrvaldes jrvaldes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mansikulkarni96 thanks for fixing this.

Do you anticipate adding e2e test coverage for this scenario?

if oldNamespace.GetName() != r.watchNamespace && newNamespace.GetName() != r.watchNamespace {
return false
}
oldValue := oldNamespace.Labels["openshift.io/cluster-monitoring"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding a const for openshift.io/cluster-monitoring, and reuse it

Copy link
Contributor

openshift-ci bot commented Jan 13, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jrvaldes
Once this PR has been reviewed and has the lgtm label, please assign mansikulkarni96 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@mansikulkarni96
Copy link
Member Author

mansikulkarni96 commented Jan 13, 2025

@mansikulkarni96 thanks for fixing this.

Do you anticipate adding e2e test coverage for this scenario?

I don't lean towards it, as adding an e2e for an event log message may not be useful . But I am open to it and need inputs from the team.

if namespace.GetName() != watchNamespace {
return false
}
if value, ok := namespace.Labels["openshift.io/cluster-monitoring"]; ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following why the label check is no longer being made

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebsoto label check is being made in the reconciler, so we can generate events if the label has not been added to the namespace.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I am not understanding the issue that is being solved.
It seems like the underlying bug is complaining about event generation indicating that monitoring is being disabled/enabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in possibly in addition to this work, you would want to keep track of the current state, and if it changes, generate an event indicating it has changed. Right now an event is generated indicating it is not enabled.

labelValue := false
wmcoNamespace, err := r.k8sclientset.CoreV1().Namespaces().Get(ctx, r.watchNamespace, metav1.GetOptions{})
if err != nil {
return false, fmt.Errorf("error getting operator namespace: %w", err)
}
// if the label exists, update value from default of false
if value, ok := wmcoNamespace.Labels["openshift.io/cluster-monitoring"]; ok {
labelValue, err = strconv.ParseBool(value)
if err != nil {
return false, fmt.Errorf("monitoring label must have a boolean value: %w", err)
}
}
if !labelValue {
r.recorder.Eventf(wmcoNamespace, v1.EventTypeWarning, "labelValidationFailed",
"Cluster monitoring openshift.io/cluster-monitoring=true label is not enabled in %s namespace",
r.watchNamespace)
}
return labelValue, nil

The followup question is, is this something that we want to do. I see some value in it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct that's the bug, this event was generated before the controller changes went in. Agreed, I see value in generating an event when there is a change.

This commit fixes the controller to generate events when the
cluster-monitoring label is updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/invalid-bug Indicates that a referenced Jira bug is invalid 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-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants