Browse Source

Not adding the docker check if we couldn't create the client

pull/1343/head
Diptanu Choudhury 9 years ago
parent
commit
423f7fbcac
  1. 3
      command/agent/agent.go
  2. 21
      command/agent/check.go

3
command/agent/agent.go

@ -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 {

21
command/agent/check.go

@ -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…
Cancel
Save