X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0f644e242ef37c911ad3dc25aca8135c339de349..e38ac44d14e9006c24c93bca9de1ee299b16d367:/services/keep-web/handler.go diff --git a/services/keep-web/handler.go b/services/keep-web/handler.go index 769c2f59ce..67d46f6716 100644 --- a/services/keep-web/handler.go +++ b/services/keep-web/handler.go @@ -21,14 +21,16 @@ import ( "git.curoverse.com/arvados.git/sdk/go/arvados" "git.curoverse.com/arvados.git/sdk/go/arvadosclient" "git.curoverse.com/arvados.git/sdk/go/auth" + "git.curoverse.com/arvados.git/sdk/go/health" "git.curoverse.com/arvados.git/sdk/go/httpserver" "git.curoverse.com/arvados.git/sdk/go/keepclient" ) type handler struct { - Config *Config - clientPool *arvadosclient.ClientPool - setupOnce sync.Once + Config *Config + clientPool *arvadosclient.ClientPool + setupOnce sync.Once + healthHandler http.Handler } // parseCollectionIDFromDNSName returns a UUID or PDH if s begins with @@ -70,7 +72,13 @@ func parseCollectionIDFromURL(s string) string { func (h *handler) setup() { h.clientPool = arvadosclient.MakeClientPool() + keepclient.RefreshServiceDiscoveryOnSIGHUP() + + h.healthHandler = &health.Handler{ + Token: h.Config.ManagementToken, + Prefix: "/_health/", + } } func (h *handler) serveStatus(w http.ResponseWriter, r *http.Request) { @@ -110,6 +118,11 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { httpserver.Log(remoteAddr, statusCode, statusText, w.WroteBodyBytes(), r.Method, r.Host, r.URL.Path, r.URL.RawQuery) }() + if strings.HasPrefix(r.URL.Path, "/_health/") && r.Method == "GET" { + h.healthHandler.ServeHTTP(w, r) + return + } + if r.Method == "OPTIONS" { method := r.Header.Get("Access-Control-Request-Method") if method != "GET" && method != "POST" { @@ -136,6 +149,7 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) { // SSL certificates. See // http://www.w3.org/TR/cors/#user-credentials). w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Expose-Headers", "Content-Range") } arv := h.clientPool.Get()