mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
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 <samuel.torres@form3.tech>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user