From 1b4502114ff70899931a6e7f6f6d32e3ed81049d Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Wed, 17 Jan 2018 14:25:26 -0800 Subject: [PATCH 1/4] etcdserver/api/etcdhttp: remove "errors" field in /health Signed-off-by: Gyuho Lee --- etcdserver/api/etcdhttp/metrics.go | 34 ++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/etcdserver/api/etcdhttp/metrics.go b/etcdserver/api/etcdhttp/metrics.go index a68d9cefd8a..f374adcaa6b 100644 --- a/etcdserver/api/etcdhttp/metrics.go +++ b/etcdserver/api/etcdhttp/metrics.go @@ -70,34 +70,32 @@ func NewHealthHandler(hfunc func() Health) http.HandlerFunc { // Health defines etcd server health status. // TODO: remove manual parsing in etcdctl cluster-health type Health struct { - Health string `json:"health"` - Errors []string `json:"errors,omitempty"` + Health string `json:"health"` } +// TODO: server NOSPACE, etcdserver.ErrNoLeader in health API + func checkHealth(srv etcdserver.ServerV2) Health { - h := Health{Health: "false"} + h := Health{Health: "true"} as := srv.Alarms() if len(as) > 0 { - for _, v := range as { - h.Errors = append(h.Errors, v.Alarm.String()) - } - return h + h.Health = "false" } - if uint64(srv.Leader()) == raft.None { - h.Errors = append(h.Errors, etcdserver.ErrNoLeader.Error()) - return h + if h.Health == "true" { + if uint64(srv.Leader()) == raft.None { + h.Health = "false" + } } - ctx, cancel := context.WithTimeout(context.Background(), time.Second) - _, err := srv.Do(ctx, etcdserverpb.Request{Method: "QGET"}) - cancel() - if err != nil { - h.Errors = append(h.Errors, err.Error()) - } - if err == nil { - h.Health = "true" + if h.Health == "true" { + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + _, err := srv.Do(ctx, etcdserverpb.Request{Method: "QGET"}) + cancel() + if err != nil { + h.Health = "false" + } } return h } From 1139d28eb6cc707ce6edcfc7337d63c197ae5513 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Wed, 17 Jan 2018 14:26:39 -0800 Subject: [PATCH 2/4] e2e: remove "/health" "errors" field test Signed-off-by: Gyuho Lee --- e2e/ctl_v3_alarm_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/ctl_v3_alarm_test.go b/e2e/ctl_v3_alarm_test.go index effdebd1b68..e0a88dd4738 100644 --- a/e2e/ctl_v3_alarm_test.go +++ b/e2e/ctl_v3_alarm_test.go @@ -53,7 +53,7 @@ func alarmTest(cx ctlCtx) { } // '/health' handler should return 'false' - if err := cURLGet(cx.epc, cURLReq{endpoint: "/health", expected: `{"health":"false","errors":["NOSPACE"]}`}); err != nil { + if err := cURLGet(cx.epc, cURLReq{endpoint: "/health", expected: `{"health":"false"}`}); err != nil { cx.t.Fatalf("failed get with curl (%v)", err) } From 8455f222853780a8353672b5fbc921b5bfce17db Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Wed, 17 Jan 2018 14:32:47 -0800 Subject: [PATCH 3/4] Documentation/upgrades: highlight "health", remove "errors" field Signed-off-by: Gyuho Lee --- Documentation/upgrades/upgrade_3_3.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/Documentation/upgrades/upgrade_3_3.md b/Documentation/upgrades/upgrade_3_3.md index b725aefcf9e..f1be1619bae 100644 --- a/Documentation/upgrades/upgrade_3_3.md +++ b/Documentation/upgrades/upgrade_3_3.md @@ -72,27 +72,17 @@ cfg.SetupLogging() Set `embed.Config.Debug` field to `true` to enable gRPC server logs. -#### Change in `/health` endpoint response value +#### Change in `/health` endpoint response -Previously, `[endpoint]:[client-port]/health` returned manually marshaled JSON value. 3.3 now defines [`etcdhttp.Health`](https://godoc.org/github.com/coreos/etcd/etcdserver/api/etcdhttp#Health) struct and includes errors, if any. Note that `"health"` field in `etcdhttp.Health` is `string` type (was boolean in v3.3.0-rc.0,1,2 but reverted to `string` for backward compatibilities). +Previously, `[endpoint]:[client-port]/health` returned manually marshaled JSON value. 3.3 now defines [`etcdhttp.Health`](https://godoc.org/github.com/coreos/etcd/etcdserver/api/etcdhttp#Health) struct. -Before +Note that in v3.3.0-rc.0, v3.3.0-rc.1, and v3.3.0-rc.2, `etcdhttp.Health` has boolean type `"health"` and `"errors"` fields. For backward compatibilities, we reverted `"health"` field to `string` type and removed `"errors"` field. Further health information will be provided in separate APIs. ```bash $ curl http://localhost:2379/health {"health":"true"} ``` -After - -```bash -$ curl http://localhost:2379/health -{"health":"true"} - -# Or -{"health":"false","errors":["NOSPACE"]} -``` - #### Change in gRPC gateway HTTP endpoints (replaced `/v3alpha` with `/v3beta`) Before From e689ff823e9d078267e1c01ebba93bd6b2951356 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Wed, 17 Jan 2018 14:38:39 -0800 Subject: [PATCH 4/4] proxy/grpcproxy: remove "Errors" field Signed-off-by: Gyuho Lee --- proxy/grpcproxy/health.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/proxy/grpcproxy/health.go b/proxy/grpcproxy/health.go index 1a6d0cf670f..e5e91f29bb3 100644 --- a/proxy/grpcproxy/health.go +++ b/proxy/grpcproxy/health.go @@ -37,8 +37,5 @@ func checkHealth(c *clientv3.Client) etcdhttp.Health { if err == nil || err == rpctypes.ErrPermissionDenied { h.Health = "true" } - if h.Health != "true" { - h.Errors = append(h.Errors, err.Error()) - } return h }