From 7555c2e705deabfe9ac15486f81b982e3dab7882 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Tue, 5 Apr 2016 10:15:38 -0700 Subject: [PATCH] Setting check state to critical if check result had an error --- client/consul/sync.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/consul/sync.go b/client/consul/sync.go index 029b3e03e..3bbec198e 100644 --- a/client/consul/sync.go +++ b/client/consul/sync.go @@ -432,9 +432,6 @@ func (c *ConsulService) runCheck(check Check) { res := check.Run() state := consul.HealthCritical output := res.Output - if res.Err != nil { - output = res.Err.Error() - } switch res.ExitCode { case 0: state = consul.HealthPassing @@ -443,6 +440,10 @@ func (c *ConsulService) runCheck(check Check) { default: state = consul.HealthCritical } + if res.Err != nil { + state = consul.HealthCritical + output = res.Err.Error() + } if err := c.client.Agent().UpdateTTL(check.ID(), output, state); err != nil { if c.availble { c.logger.Printf("[DEBUG] error updating ttl check for check %q: %v", check.ID(), err)