Better error from /nodes when Store is not open

This commit is contained in:
Philip O'Toole
2022-10-28 11:34:28 -04:00
parent 4ab4b08049
commit 9c68b13868

View File

@@ -959,8 +959,11 @@ func (s *Service) handleNodes(w http.ResponseWriter, r *http.Request) {
// Get nodes in the cluster, and possibly filter out non-voters.
nodes, err := s.store.Nodes()
if err != nil {
http.Error(w, fmt.Sprintf("store nodes: %s", err.Error()),
http.StatusInternalServerError)
statusCode := http.StatusInternalServerError
if err == store.ErrNotOpen {
statusCode = http.StatusServiceUnavailable
}
http.Error(w, fmt.Sprintf("store nodes: %s", err.Error()), statusCode)
return
}