mirror of https://github.com/hashicorp/consul
Not adding the docker check if we couldn't create the client
parent
f5f5ed0c79
commit
423f7fbcac
|
@ -928,6 +928,9 @@ func (a *Agent) AddCheck(check *structs.HealthCheck, chkType *CheckType, persist
|
|||
Interval: chkType.Interval,
|
||||
Logger: a.logger,
|
||||
}
|
||||
if err := dockerCheck.Init(); err != nil {
|
||||
return err
|
||||
}
|
||||
dockerCheck.Start()
|
||||
a.checkDockers[check.CheckID] = dockerCheck
|
||||
} else {
|
||||
|
|
|
@ -530,21 +530,24 @@ type CheckDocker struct {
|
|||
stopLock sync.Mutex
|
||||
}
|
||||
|
||||
//Initializes the Docker Client
|
||||
func (c *CheckDocker) Init() error {
|
||||
//create the docker client
|
||||
var err error
|
||||
c.dockerClient, err = docker.NewClientFromEnv()
|
||||
if err != nil {
|
||||
c.Logger.Println("[DEBUG] Error creating the Docker Client : %s", err.Error())
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Start is used to start checks.
|
||||
// Docker Checks runs until stop is called
|
||||
func (c *CheckDocker) Start() {
|
||||
c.stopLock.Lock()
|
||||
defer c.stopLock.Unlock()
|
||||
|
||||
//create the docker client
|
||||
if c.dockerClient == nil {
|
||||
var err error
|
||||
c.dockerClient, err = docker.NewClientFromEnv()
|
||||
if err != nil {
|
||||
c.Logger.Println("[DEBUG] Error creating the Docker Client : %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
//figure out the shell
|
||||
if c.Shell == "" {
|
||||
c.Shell = shell()
|
||||
|
|
Loading…
Reference in New Issue