Skip to content

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

Conversation

andyxning
Copy link
Member

Fix #202

/cc @aga20

@k8s-ci-robot
Copy link
Contributor

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

Fix #202

/cc @aga20

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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 10, 2018
@andyxning andyxning force-pushed the fix_custom_plugin_monitor_condition_change branch 2 times, most recently from d68b761 to 34ce300 Compare September 10, 2018 06:29
@@ -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 {
Copy link
Member

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

Copy link
Member

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.

Copy link
Member

@Random-Liu Random-Liu Sep 14, 2018

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?

Copy link
Member Author

@andyxning andyxning Nov 12, 2018

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 {
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

}
condition.Status = status
Copy link
Member

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.

Copy link
Member Author

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.

@aga20
Copy link

aga20 commented Nov 19, 2018

Seems ok with manual testing!


condition.Status = status
condition.Reason = result.Rule.Reason
} else if condition.Status == status && condition.Message != result.Message {
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

@andyxning Address this?

@Random-Liu
Copy link
Member

I'll merged this now and we'll send a fix for #203 (comment).

@Random-Liu
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 27, 2018
@k8s-ci-robot
Copy link
Contributor

[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:
  • OWNERS [Random-Liu,andyxning]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit d793330 into kubernetes:master Nov 27, 2018
@andyxning andyxning deleted the fix_custom_plugin_monitor_condition_change branch December 10, 2018 02:57
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants