From df5859580fbb80dea8777d396702ef1d39003b58 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Thu, 6 Nov 2014 18:24:04 -0800 Subject: [PATCH] agent: pass notes field through for checks inside of service definitions. Fixes #449 --- command/agent/agent.go | 2 +- command/agent/agent_test.go | 10 +++++++++- command/agent/check.go | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/command/agent/agent.go b/command/agent/agent.go index c3b34f5465..9ef0711377 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -447,7 +447,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.HealthCritical, - Notes: "", + Notes: chkType.Notes, ServiceID: service.ID, ServiceName: service.Service, } diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index dff36507b5..2901d67bc2 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -115,7 +115,10 @@ func TestAgent_AddService(t *testing.T) { Tags: []string{"foo"}, Port: 8000, } - chk := &CheckType{TTL: time.Minute} + chk := &CheckType{ + TTL: time.Minute, + Notes: "redis health check", + } err := agent.AddService(srv, chk) if err != nil { t.Fatalf("err: %v", err) @@ -135,6 +138,11 @@ func TestAgent_AddService(t *testing.T) { if _, ok := agent.checkTTLs["service:redis"]; !ok { t.Fatalf("missing redis check ttl") } + + // Ensure the notes are passed through + if agent.state.Checks()["service:redis"].Notes == "" { + t.Fatalf("missing redis check notes") + } } func TestAgent_RemoveService(t *testing.T) { diff --git a/command/agent/check.go b/command/agent/check.go index dce7d8f75c..a2cb588dd6 100644 --- a/command/agent/check.go +++ b/command/agent/check.go @@ -30,6 +30,8 @@ type CheckType struct { Interval time.Duration TTL time.Duration + + Notes string } // Valid checks if the CheckType is valid