Skip to content

Commit

Permalink
Return installation ID as part of health check response (#964)
Browse files Browse the repository at this point in the history
  • Loading branch information
nopcoder authored Nov 26, 2020
1 parent 84a52ee commit 04e6499
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cmd/lakefs/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down
15 changes: 12 additions & 3 deletions httputil/endpoints.go
Original file line number Diff line number Diff line change
@@ -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)
}
})
}

Expand Down

0 comments on commit 04e6499

Please sign in to comment.