-
Notifications
You must be signed in to change notification settings - Fork 655
fix custom plugin monitor condition change #203
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 custom plugin monitor condition change #203
Conversation
@andyxning: GitHub didn't allow me to request PR reviews from the following users: aga20. Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs. 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. |
d68b761
to
34ce300
Compare
@@ -126,7 +126,8 @@ func (c *customPluginMonitor) generateStatus(result cpmtypes.Result) *types.Stat | |||
condition := &c.conditions[i] | |||
if condition.Type == result.Rule.Condition { | |||
status := toConditionStatus(result.ExitStatus) | |||
if condition.Status != status || condition.Reason != result.Rule.Reason { | |||
// change 1: Condition status change from True to False/Unknown | |||
if condition.Status != status && condition.Status == types.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.
condition.Status == types.True && status != types.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.
IIRC, true
means there is a problem, false
means there is no problem. If so, we should reset default 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.
@andyxning What about this? I feel like the current logic in your change is just opposite.
In your code:
status true -> false: reason is updated;
status false -> true: reason is reset to default.
Is that correct?
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.
What about this? I feel like the current logic in your change is just opposite.
In your code:
status true -> false: reason is updated;
status false -> true: reason is reset to default.
Is that correct?
After a re-think, i am wrong. I will update this.
|
||
condition.Status = status | ||
condition.Reason = result.Rule.Reason | ||
} else if condition.Status != status && status == types.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.
condition.Status != types.True && status == types.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.
Done
} | ||
condition.Status = status |
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 feel like most code in the if-else clause can be extracted out.
At least event generation can be extracted.
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.
Yes. Some code refactor needs to be done. But i prefer we do little refactor on this to make the code more clear for others.
34ce300
to
e3b3771
Compare
Seems ok with manual testing! |
|
||
condition.Status = status | ||
condition.Reason = result.Rule.Reason | ||
} else if condition.Status == status && condition.Message != result.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.
WE should only update condition when reason changes.
Message could be spammy and change a lot. See https://github.com/kubernetes/node-problem-detector/blob/master/pkg/systemlogmonitor/log_monitor.go#L142
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.
@andyxning Address this?
I'll merged this now and we'll send a fix for #203 (comment). |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andyxning, Random-Liu 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 |
Fix #202
/cc @aga20