Better ready response
@@ -844,15 +844,18 @@ func (s *Service) handleReadyz(w http.ResponseWriter, r *http.Request) {
}
if lAddr != "" {
- if _, err := s.cluster.GetNodeAPIAddr(lAddr, timeout); err == nil {
+ _, err = s.cluster.GetNodeAPIAddr(lAddr, timeout)
+ if err != nil {
+ w.WriteHeader(http.StatusServiceUnavailable)
+ w.Write([]byte(fmt.Sprintf("[+]leader not contactable: %s", err.Error())))
+ return
+ }
w.WriteHeader(http.StatusOK)
w.Write([]byte("[+]leader ok"))
return
}
- }
-
- http.Error(w, fmt.Sprintf("no leader: %s", err.Error()),
- http.StatusServiceUnavailable)
+ w.WriteHeader(http.StatusServiceUnavailable)
+ w.Write([]byte("[+]leader does not exist"))
}
// handleExecute handles queries that modify the database.
