15954: Add ping check for health aggregator.
authorTom Clegg <tom@tomclegg.ca>
Mon, 27 Jan 2020 16:39:34 +0000 (11:39 -0500)
committerTom Clegg <tom@tomclegg.ca>
Mon, 27 Jan 2020 16:39:34 +0000 (11:39 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

sdk/go/health/aggregator.go

index a1ef5e0beb76d8c95cef9c0b9ec5a2dbe8df9eae..90823b38b015351ce3c8b24926de4c98f894efed 100644 (file)
@@ -62,11 +62,14 @@ func (agg *Aggregator) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
                sendErr(http.StatusUnauthorized, errUnauthorized)
                return
        }
-       if req.URL.Path != "/_health/all" {
+       if req.URL.Path == "/_health/all" {
+               json.NewEncoder(resp).Encode(agg.ClusterHealth())
+       } else if req.URL.Path == "/_health/ping" {
+               resp.Write(healthyBody)
+       } else {
                sendErr(http.StatusNotFound, errNotFound)
                return
        }
-       json.NewEncoder(resp).Encode(agg.ClusterHealth())
        if agg.Log != nil {
                agg.Log(req, nil)
        }