From 275d2b929a6622cca5d93bd17c3409b837cb2a86 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 30 Jun 2018 07:37:43 -0700 Subject: [PATCH] agent/checks: set critical if RPC fails --- agent/checks/alias.go | 5 +++++ agent/checks/alias_test.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/agent/checks/alias.go b/agent/checks/alias.go index 72963adb5..9622c896c 100644 --- a/agent/checks/alias.go +++ b/agent/checks/alias.go @@ -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 } diff --git a/agent/checks/alias_test.go b/agent/checks/alias_test.go index e063451b3..220f5a85f 100644 --- a/agent/checks/alias_test.go +++ b/agent/checks/alias_test.go @@ -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.