diff --git a/command/agent/agent.go b/command/agent/agent.go index ca816ff27f..5d5e46584f 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -359,7 +359,7 @@ func (a *Agent) AddService(service *structs.NodeService, chkType *CheckType) err CheckID: fmt.Sprintf("service:%s", service.ID), Name: fmt.Sprintf("Service '%s' check", service.Service), Status: structs.HealthUnknown, - Notes: "Initializing", + Notes: "", ServiceID: service.ID, ServiceName: service.Service, } diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 71d960039c..85d30c8ab7 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -308,7 +308,7 @@ func TestAgent_UpdateCheck(t *testing.T) { if status.Status != structs.HealthPassing { t.Fatalf("bad: %v", status) } - if status.Notes != "foo" { + if status.Output != "foo" { t.Fatalf("bad: %v", status) } } diff --git a/command/agent/check.go b/command/agent/check.go index f79aaff966..0f639311f2 100644 --- a/command/agent/check.go +++ b/command/agent/check.go @@ -47,7 +47,7 @@ func (c *CheckType) IsMonitor() bool { // to notify when a check has a status update. The update // should take care to be idempotent. type CheckNotifier interface { - UpdateCheck(checkID, status, note string) + UpdateCheck(checkID, status, output string) } // CheckMonitor is used to periodically invoke a script to @@ -137,14 +137,14 @@ func (c *CheckMonitor) check() { }() err := <-errCh - notes := string(output.Bytes()) + outputStr := string(output.Bytes()) c.Logger.Printf("[DEBUG] agent: check '%s' script '%s' output: %s", - c.CheckID, c.Script, notes) + c.CheckID, c.Script, outputStr) // Check if the check passed if err == nil { c.Logger.Printf("[DEBUG] Check '%v' is passing", c.CheckID) - c.Notify.UpdateCheck(c.CheckID, structs.HealthPassing, notes) + c.Notify.UpdateCheck(c.CheckID, structs.HealthPassing, outputStr) return } @@ -155,7 +155,7 @@ func (c *CheckMonitor) check() { code := status.ExitStatus() if code == 1 { c.Logger.Printf("[WARN] Check '%v' is now warning", c.CheckID) - c.Notify.UpdateCheck(c.CheckID, structs.HealthWarning, notes) + c.Notify.UpdateCheck(c.CheckID, structs.HealthWarning, outputStr) return } } @@ -163,7 +163,7 @@ func (c *CheckMonitor) check() { // Set the health as critical c.Logger.Printf("[WARN] Check '%v' is now critical", c.CheckID) - c.Notify.UpdateCheck(c.CheckID, structs.HealthCritical, notes) + c.Notify.UpdateCheck(c.CheckID, structs.HealthCritical, outputStr) } // CheckTTL is used to apply a TTL to check status, @@ -221,9 +221,9 @@ func (c *CheckTTL) run() { // SetStatus is used to update the status of the check, // and to renew the TTL. If expired, TTL is restarted. -func (c *CheckTTL) SetStatus(status, note string) { +func (c *CheckTTL) SetStatus(status, output string) { c.Logger.Printf("[DEBUG] Check '%v' status is now %v", c.CheckID, status) - c.Notify.UpdateCheck(c.CheckID, status, note) + c.Notify.UpdateCheck(c.CheckID, status, output) c.timer.Reset(c.TTL) } diff --git a/command/agent/local.go b/command/agent/local.go index 726162aabc..9254564bf2 100644 --- a/command/agent/local.go +++ b/command/agent/local.go @@ -186,13 +186,13 @@ func (l *localState) UpdateCheck(checkID, status, output string) { } // Do nothing if update is idempotent - if check.Status == status && check.Notes == output { + if check.Status == status && check.Output == output { return } // Update status and mark out of sync check.Status = status - check.Notes = output + check.Output = output l.checkStatus[checkID] = syncStatus{inSync: false} l.changeMade() } diff --git a/consul/structs/structs.go b/consul/structs/structs.go index 2aac5ee982..1ebfae6a4e 100644 --- a/consul/structs/structs.go +++ b/consul/structs/structs.go @@ -205,6 +205,7 @@ type HealthCheck struct { Name string // Check name Status string // The current check status Notes string // Additional notes with the status + Output string // Holds output of script runs ServiceID string // optional associated service ServiceName string // optional service name }