From 66b232f53e102fc5152beb64ec393f3bda8f84b3 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Thu, 30 Jan 2014 13:17:34 -0800 Subject: [PATCH] agent: syncCheck provides the relevant check to prevent a race condition --- command/agent/local.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/command/agent/local.go b/command/agent/local.go index 455a458ad5..06c3917977 100644 --- a/command/agent/local.go +++ b/command/agent/local.go @@ -352,10 +352,19 @@ func (l *localState) syncService(id string) error { // syncCheck is used to sync a service to the server func (l *localState) syncCheck(id string) error { + // Pull in the associated service if any + check := l.checks[id] + var service *structs.NodeService + if check.ServiceID != "" { + if serv, ok := l.services[check.ServiceID]; ok { + service = serv + } + } req := structs.RegisterRequest{ Datacenter: l.config.Datacenter, Node: l.config.NodeName, Address: l.config.AdvertiseAddr, + Service: service, Check: l.checks[id], } var out struct{}