-
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
api/etcdhttp: serve error information in '/health', marshal health in JSON #8312
Conversation
etcdserver/api/etcdhttp/metrics.go
Outdated
} | ||
|
||
func (h health) marshal() string { | ||
s := fmt.Sprintf(`{"health": "%v"`, h.Health) |
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.
probably just use json encoding.
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.
Then {"health": "true"}
becomes {"health":true}
. Possibly break backward compatibility?
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 am not sure if this is that important... the previous "true" is a mistake. we should change it to either "health": "ok" or "health": true. @heyitsanthony opinion?
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 doubt it can be safely changed.
@xiang90 @heyitsanthony PTAL. Thanks. |
@@ -57,7 +58,7 @@ func newHealthHandler(srv *etcdserver.EtcdServer) http.HandlerFunc { | |||
return | |||
} | |||
h := checkHealth(srv) | |||
d := []byte(fmt.Sprintf(`{"health": "%v"}`, h.Health)) | |||
d, _ := json.Marshal(h) |
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.
needs a TODO about removing {"health" : "true"}
from etcdctl cluster-health in the future; I don't think it can be done in the same minor rev without breaking compat
Documentation/v2/admin_guide.md
Outdated
@@ -45,12 +45,12 @@ It is important to monitor your production etcd cluster for healthy information | |||
|
|||
#### Health Monitoring | |||
|
|||
At lowest level, etcd exposes health information via HTTP at `/health` in JSON format. If it returns `{"health": "true"}`, then the cluster is healthy. Please note the `/health` endpoint is still an experimental one as in etcd 2.2. | |||
At lowest level, etcd exposes health information via HTTP at `/health` in JSON format. If it returns `{"health":true}`, then the cluster is healthy. Please note the `/health` endpoint is still an experimental one as in etcd 2.2. |
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.
Is this really still experimental? It seems people depend on cluster-health which depends on /health
@heyitsanthony Added TODO on |
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.
lgtm after rpctypes fixup; thanks
etcdserver/api/etcdhttp/metrics.go
Outdated
return h | ||
} | ||
|
||
if uint64(srv.Leader()) == raft.None { | ||
h.Errors = append(h.Errors, rpctypes.ErrNoLeader.Error()) |
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.
probably should be etcdserver.ErrNoLeader
to avoid the rpctypes dep
… JSON Signed-off-by: Gyu-Ho Lee <[email protected]>
Signed-off-by: Gyu-Ho Lee <[email protected]>
No description provided.