@@ -7,13 +7,16 @@ import (
77 "net/http"
88 "time"
99
10+ stdjson "encoding/json"
11+
1012 "github.com/gorilla/rpc/v2"
1113
1214 "github.com/ava-labs/avalanchego/health"
13- healthlib "github.com/ava-labs/avalanchego/health"
1415 "github.com/ava-labs/avalanchego/snow/engine/common"
1516 "github.com/ava-labs/avalanchego/utils/json"
1617 "github.com/ava-labs/avalanchego/utils/logging"
18+
19+ healthlib "github.com/ava-labs/avalanchego/health"
1720)
1821
1922// Service wraps a [healthlib.Service]. Handler() returns a handler
@@ -74,15 +77,25 @@ type APIHealthReply struct {
7477func (as * apiServer ) Health (_ * http.Request , _ * APIHealthArgs , reply * APIHealthReply ) error {
7578 as .log .Info ("Health.health called" )
7679 reply .Checks , reply .Healthy = as .Results ()
77- return nil
80+ if reply .Healthy {
81+ return nil
82+ }
83+ replyStr , err := stdjson .Marshal (reply .Checks )
84+ as .log .Warn ("Health.health is returning an error: %s" , string (replyStr ))
85+ return err
7886}
7987
8088// GetLiveness returns a summation of the health of the node
8189// Deprecated: in favor of Health
8290func (as * apiServer ) GetLiveness (_ * http.Request , _ * APIHealthArgs , reply * APIHealthReply ) error {
83- as .log .Info ("Health: GetLiveness called" )
91+ as .log .Info ("Health.getLiveness called" )
8492 reply .Checks , reply .Healthy = as .Results ()
85- return nil
93+ if reply .Healthy {
94+ return nil
95+ }
96+ replyStr , err := stdjson .Marshal (reply .Checks )
97+ as .log .Warn ("Health.getLiveness is returning an error: %s" , string (replyStr ))
98+ return err
8699}
87100
88101type noOp struct {}
0 commit comments