1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-06-19 05:10:02 +02:00

src/api: do not send a message in haproxy response (it does not like that).

This commit is contained in:
Henrik Hautakoski 2022-08-12 17:16:01 +02:00
parent ed91320a1d
commit 879d613b46
No known key found for this signature in database
GPG key ID: 608414D93E862CCD
3 changed files with 14 additions and 23 deletions

View file

@ -39,13 +39,13 @@ func (e EosioV2) Call() (agentcheck.Response, string) {
health, err := eosapi.GetHealth(e.params)
if err != nil {
resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "Failed to contact api")
resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")
return resp, err.Error()
}
// Check HTTP Status Code
if health.HTTPStatusCode > 299 {
resp := agentcheck.NewStatusMessageResponse(agentcheck.Down, fmt.Sprintf("HTTP %v", health.HTTPStatusCode))
resp := agentcheck.NewStatusMessageResponse(agentcheck.Down, "")
return resp, fmt.Sprintf("Taking offline because %v was received from backend", health.HTTPStatusCode)
}
@ -66,19 +66,17 @@ func (e EosioV2) Call() (agentcheck.Response, string) {
msg := fmt.Sprintf("Failed to get Elasticsearch and/or nodeos " +
"block numbers (es: %d, eos: %d)", es_block, node_block)
resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, msg)
resp := agentcheck.NewStatusMessageResponse(agentcheck.Failed, "")
return resp, msg
}
// Check if ES is behind or in the future.
diff := node_block - es_block;
if diff > e.offset {
resp := agentcheck.NewStatusMessageResponse(agentcheck.Down,
fmt.Sprintf("Elastic is %d blocks behind", diff))
resp := agentcheck.NewStatusMessageResponse(agentcheck.Down, "")
return resp, fmt.Sprintf("Taking offline because Elastic is %d blocks behind", diff)
} else if diff < -e.offset {
resp := agentcheck.NewStatusMessageResponse(agentcheck.Down,
fmt.Sprintf("Elastic is %d blocks into the future", -1 * diff))
resp := agentcheck.NewStatusMessageResponse(agentcheck.Down, "")
return resp, fmt.Sprintf("Taking offline because Elastic is %d blocks into the future", -1 * diff)
}
return agentcheck.NewStatusResponse(agentcheck.Up), "OK"