Fix /health REST API panic (#763)

* fix: panic in REST health endpoint to running node without RLN

* chore: change title of each API file
This commit is contained in:
Prem Chaitanya Prathi 2023-09-21 18:40:07 +05:30 committed by GitHub
parent d317b294a0
commit 3254d28968
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 15 deletions

View File

@ -1,6 +1,6 @@
openapi: 3.0.3
info:
title: Waku V2 node REST API
title: Waku V2 node Debug REST API
version: 1.0.0
contact:
name: VAC Team

View File

@ -30,19 +30,23 @@ func NewHealthService(node *node.WakuNode, m *chi.Mux) *HealthService {
type HealthResponse string
func (d *HealthService) getHealth(w http.ResponseWriter, r *http.Request) {
isReady, err := d.node.RLNRelay().IsReady(r.Context())
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
writeResponse(w, HealthResponse("Health check timed out"), http.StatusInternalServerError)
} else {
writeResponse(w, HealthResponse(err.Error()), http.StatusInternalServerError)
if d.node.RLNRelay() != nil {
isReady, err := d.node.RLNRelay().IsReady(r.Context())
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
writeResponse(w, HealthResponse("Health check timed out"), http.StatusInternalServerError)
} else {
writeResponse(w, HealthResponse(err.Error()), http.StatusInternalServerError)
}
return
}
return
}
if isReady {
writeResponse(w, HealthResponse("Node is healthy"), http.StatusOK)
if isReady {
writeResponse(w, HealthResponse("Node is healthy"), http.StatusOK)
} else {
writeResponse(w, HealthResponse("Node is not ready"), http.StatusInternalServerError)
}
} else {
writeResponse(w, HealthResponse("Node is not ready"), http.StatusInternalServerError)
writeResponse(w, HealthResponse("Non RLN healthcheck is not implemented"), http.StatusNotImplemented)
}
}

View File

@ -1,6 +1,6 @@
openapi: 3.0.3
info:
title: Waku V2 node REST API
title: Waku V2 node Health REST API
version: 1.0.0
contact:
name: VAC Team

View File

@ -1,6 +1,6 @@
openapi: 3.0.3
info:
title: Waku V2 node REST API
title: Waku V2 node Relay REST API
version: 1.0.0
contact:
name: VAC Team

View File

@ -1,6 +1,6 @@
openapi: 3.0.3
info:
title: Waku V2 node REST API
title: Waku V2 node Store REST API
version: 1.0.0
contact:
name: VAC Team