mirror of https://github.com/hashicorp/consul
agent: pass notes field through for checks inside of service definitions. Fixes #449
parent
1756d14e01
commit
df5859580f
|
@ -447,7 +447,7 @@ func (a *Agent) AddService(service *structs.NodeService, chkType *CheckType) err
|
||||||
CheckID: fmt.Sprintf("service:%s", service.ID),
|
CheckID: fmt.Sprintf("service:%s", service.ID),
|
||||||
Name: fmt.Sprintf("Service '%s' check", service.Service),
|
Name: fmt.Sprintf("Service '%s' check", service.Service),
|
||||||
Status: structs.HealthCritical,
|
Status: structs.HealthCritical,
|
||||||
Notes: "",
|
Notes: chkType.Notes,
|
||||||
ServiceID: service.ID,
|
ServiceID: service.ID,
|
||||||
ServiceName: service.Service,
|
ServiceName: service.Service,
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,10 @@ func TestAgent_AddService(t *testing.T) {
|
||||||
Tags: []string{"foo"},
|
Tags: []string{"foo"},
|
||||||
Port: 8000,
|
Port: 8000,
|
||||||
}
|
}
|
||||||
chk := &CheckType{TTL: time.Minute}
|
chk := &CheckType{
|
||||||
|
TTL: time.Minute,
|
||||||
|
Notes: "redis health check",
|
||||||
|
}
|
||||||
err := agent.AddService(srv, chk)
|
err := agent.AddService(srv, chk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
|
@ -135,6 +138,11 @@ func TestAgent_AddService(t *testing.T) {
|
||||||
if _, ok := agent.checkTTLs["service:redis"]; !ok {
|
if _, ok := agent.checkTTLs["service:redis"]; !ok {
|
||||||
t.Fatalf("missing redis check ttl")
|
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) {
|
func TestAgent_RemoveService(t *testing.T) {
|
||||||
|
|
|
@ -30,6 +30,8 @@ type CheckType struct {
|
||||||
Interval time.Duration
|
Interval time.Duration
|
||||||
|
|
||||||
TTL time.Duration
|
TTL time.Duration
|
||||||
|
|
||||||
|
Notes string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid checks if the CheckType is valid
|
// Valid checks if the CheckType is valid
|
||||||
|
|
Loading…
Reference in New Issue