From f66069a08dfed3b56420c66ac983538f0ee2e2b7 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Wed, 25 Nov 2015 15:17:27 -0800 Subject: [PATCH] Using the service id in check hash --- client/consul.go | 2 +- nomad/structs/structs.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/consul.go b/client/consul.go index d60c0d744..2712cff4d 100644 --- a/client/consul.go +++ b/client/consul.go @@ -270,7 +270,7 @@ func (c *ConsulService) makeChecks(service *structs.Service, ip string, port int check.Name = fmt.Sprintf("service: '%s' check", service.Name) } cr := &consul.AgentCheckRegistration{ - ID: check.Hash(), + ID: check.Hash(service.Id), Name: check.Name, ServiceID: service.Id, } diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 8aaf0e7ef..5af0cec48 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -1040,8 +1040,9 @@ func (sc *ServiceCheck) Validate() error { return nil } -func (sc *ServiceCheck) Hash() string { +func (sc *ServiceCheck) Hash(serviceId string) string { h := sha1.New() + io.WriteString(h, serviceId) io.WriteString(h, sc.Name) io.WriteString(h, sc.Type) io.WriteString(h, sc.Script)