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 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) } 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 } 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 }