From 04e64995b25f13c1c01de9ed4597161c075c6d1d Mon Sep 17 00:00:00 2001 From: Barak Amar Date: Thu, 26 Nov 2020 10:56:32 +0200 Subject: [PATCH] Return installation ID as part of health check response (#964) --- cmd/lakefs/cmd/run.go | 2 ++ httputil/endpoints.go | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/lakefs/cmd/run.go b/cmd/lakefs/cmd/run.go index 917d6fad550..ca6aa3c498d 100644 --- a/cmd/lakefs/cmd/run.go +++ b/cmd/lakefs/cmd/run.go @@ -88,6 +88,8 @@ var runCmd = &cobra.Command{ bufferedCollector := stats.NewBufferedCollector(metadata.InstallationID, cfg) // send metadata bufferedCollector.CollectMetadata(metadata) + // update health info with installation ID + httputil.SetHealthHandlerInfo(metadata.InstallationID) dedupCleaner := dedup.NewCleaner(blockStore, cataloger.DedupReportChannel()) diff --git a/httputil/endpoints.go b/httputil/endpoints.go index a523bb0cbf3..f7983d64e56 100644 --- a/httputil/endpoints.go +++ b/httputil/endpoints.go @@ -1,15 +1,24 @@ package httputil import ( + "io" "net/http" "net/http/pprof" "strings" ) +var healthInfo string + +func SetHealthHandlerInfo(info string) { + healthInfo = info +} + func ServeHealth() http.Handler { - return http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) { - writer.WriteHeader(http.StatusOK) - _, _ = writer.Write([]byte("alive!")) + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + _, _ = io.WriteString(w, "alive!") + if healthInfo != "" { + _, _ = io.WriteString(w, " "+healthInfo) + } }) }