-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Enhance health command to check if there are any active alarms #12150
Conversation
etcdctl/ctlv3/command/ep_command.go
Outdated
|
||
if eh.Health == true { | ||
resp, err := cli.AlarmList(ctx) | ||
if err == nil { |
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.
Break out on the not error case. Save one indentation to make code cleaner.
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.
@xiang90 Have reduced one indentation level and committed again (after squashing).
LGTH after clean up the code a little bit. There is no test. But have you tried it manually? |
Could you provide an example output of this command? |
@jingyih Please see below: |
28f86c4
to
cb75ef4
Compare
@xiang90 Yes. Please refer to snapshots pasted in other message. |
|
||
if eh.Health == true { | ||
resp, err := cli.AlarmList(ctx) | ||
if err == nil && len(resp.Alarms) > 0 { |
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.
if err != nil
, eh.Health
should be false
?
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.
@jingyih By default, eh.Health is set to false. If the "cli.get" call fails, it means key-based health check has failed and hence no need to check for alarm-based health check. Only if key-based health check succeeds (which means eh.Health is set to true), alarm-based health check is performed.
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.
Oh sorry I was referring to the err
on line 138. If we cannot get alarm list, i.e., cli.AlarmList
returns a non-nil err, the health check should also fail, right?
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.
@jingyih Oh sorry for missing this. Made code change and committed again.
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.
@jingyih Can you please review this and commit (if change is acceptable)?
cb75ef4
to
ec985c0
Compare
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.
Sorry for the late response. The logic looks right to me. Just one nit.
etcdctl/ctlv3/command/ep_command.go
Outdated
@@ -16,6 +16,7 @@ package command | |||
|
|||
import ( | |||
"fmt" | |||
"go.etcd.io/etcd/v3/etcdserver/etcdserverpb" |
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.
nit: move this to the next code block (i.e., somewhere around line 24)
/cc @agargi can you resolve the one nit? then it should be ready for merging. thanks! |
0d33d59
to
a94f6da
Compare
@ptabor Can you pls help here resolve the conflict? You made re-alignment around package names but I'm not sure why I'm getting a conflict (since I have now added a new import as per the new structure). https://github.com/etcd-io/etcd/pull/12150/conflicts |
Rebasing this commit on top of current master should solve the problem:
|
a94f6da
to
28cd807
Compare
command: Enhance health command to check if there are any active alarms
Enhanced "etcdctl endpoint health" to check alarms (in addition to checking quorum read on a key). Fixes 12032