From 9868bb71a72fc720c8efd36f1690e9bac8a24168 Mon Sep 17 00:00:00 2001 From: Samuel Torres Date: Wed, 30 Mar 2022 13:55:58 +0100 Subject: [PATCH] Add logs to healthcheck handler Kubernetes probes don't use nor log the reponse body of health endpoints. This means that for some reason a nats node running in Kubernetes becomes on a Not Ready state we won't have a way to know why other than to manually access the cluster and call the /healthz endpoint manually and see the error. This change adds an error log so we can observe what is going wrong with a nats node that is not ready. Signed-off-by: Samuel Torres --- server/monitor.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/monitor.go b/server/monitor.go index 18b9d2bd..5b29ba4c 100644 --- a/server/monitor.go +++ b/server/monitor.go @@ -2768,6 +2768,7 @@ func (s *Server) HandleHealthz(w http.ResponseWriter, r *http.Request) { hs := s.healthz() if hs.Error != _EMPTY_ { + s.Warnf("Healthcheck failed: %q", hs.Error) w.WriteHeader(http.StatusServiceUnavailable) } b, err := json.Marshal(hs)