agent/checks: set critical if RPC fails

This commit is contained in:
Mitchell Hashimoto 2018-06-30 07:37:43 -07:00
parent 175e74972d
commit 275d2b929a
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 11 additions and 0 deletions

View File

@ -137,6 +137,11 @@ func (c *CheckAlias) runQuery(stopCh chan struct{}) {
var out structs.IndexedHealthChecks
if err := c.RPC.RPC("Health.NodeChecks", &args, &out); err != nil {
attempt++
if attempt > 1 {
c.Notify.UpdateCheck(c.CheckID, api.HealthCritical,
fmt.Sprintf("Failure checking aliased node or service: %s", err))
}
continue
}

View File

@ -39,6 +39,12 @@ func TestCheckAlias_remoteErrBackoff(t *testing.T) {
if got, want := atomic.LoadUint32(&rpc.Calls), uint32(6); got > want {
t.Fatalf("got %d updates want at most %d", got, want)
}
retry.Run(t, func(r *retry.R) {
if got, want := notify.State(chkID), api.HealthCritical; got != want {
r.Fatalf("got state %q want %q", got, want)
}
})
}
// No remote health checks should result in passing on the check.