Fixed CR defects

This commit is contained in:
capone 2016-08-24 01:33:44 +03:00
parent 10cc50ad29
commit ce4d236a40
2 changed files with 4 additions and 7 deletions

View file

@ -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()

View file

@ -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()
}
}