diff --git a/command/agent/consul/check.go b/command/agent/consul/check.go index 1b601ea36..551f94b6f 100644 --- a/command/agent/consul/check.go +++ b/command/agent/consul/check.go @@ -47,6 +47,7 @@ func (r *CheckRunner) Start() { r.started = true } +// Started returns if the check runner has started running func (r *CheckRunner) Started() bool { r.startedLock.Lock() defer r.startedLock.Unlock() diff --git a/command/agent/consul/syncer.go b/command/agent/consul/syncer.go index f7d78f7ef..8ac66fd9f 100644 --- a/command/agent/consul/syncer.go +++ b/command/agent/consul/syncer.go @@ -687,16 +687,12 @@ func (c *Syncer) registerCheck(chkReg *consul.AgentCheckRegistration) error { return c.client.Agent().CheckRegister(chkReg) } -// ensureCheckRunning verifies that registerd check is in running state +// ensureCheckRunning starts the check runner for a check if it's not already running func (c *Syncer) ensureCheckRunning(chk *consul.AgentCheckRegistration) { c.registryLock.RLock() defer c.registryLock.RUnlock() - cr, ok := c.checkRunners[consulCheckID(chk.ID)] - if !ok { - return - } - if !cr.Started() { - c.logger.Printf("[DEBUG] ensureCheckRunning Running existing check. %v", chk) + if cr, ok := c.checkRunners[consulCheckID(chk.ID)]; ok && !cr.Started() { + c.logger.Printf("[DEBUG] consul.syncer: starting runner for existing check. %v", chk.ID) cr.Start() } }