-
Notifications
You must be signed in to change notification settings - Fork 68
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
base: master
Are you sure you want to change the base?
Conversation
Skipping CI for Draft Pull Request. |
@mansikulkarni96: This pull request references Jira Issue OCPBUGS-45027, 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 openshift-eng/jira-lifecycle-plugin repository. |
/approve cancel |
/test aws-e2e-operator |
@mansikulkarni96: The following test failed, say
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. |
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.
@mansikulkarni96 thanks for fixing this.
Do you anticipate adding e2e test coverage for this scenario?
controllers/metric_controller.go
Outdated
if oldNamespace.GetName() != r.watchNamespace && newNamespace.GetName() != r.watchNamespace { | ||
return false | ||
} | ||
oldValue := oldNamespace.Labels["openshift.io/cluster-monitoring"] |
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.
consider adding a const for openshift.io/cluster-monitoring
, and reuse it
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jrvaldes 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 |
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 { |
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'm not following why the label check is no longer being made
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.
@sebsoto label check is being made in the reconciler, so we can generate events if the label has not been added to the 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.
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.
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 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.
windows-machine-config-operator/controllers/metric_controller.go
Lines 93 to 110 in 641adab
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.
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.
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.
269583c
to
a9d5aad
Compare
This commit fixes the controller to generate events when the cluster-monitoring label is updated.
56ab11e
to
173e4ec
Compare
This commit fixes the controller to generate events when the cluster-monitoring label is not present or removed from the operator namespace.