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)