Fix error handling for docker swarm mode
This commit is contained in:
parent
447109e868
commit
984ea1040f
1 changed files with 7 additions and 0 deletions
|
@ -153,15 +153,18 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s
|
||||||
if p.Watch {
|
if p.Watch {
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
if p.SwarmMode {
|
if p.SwarmMode {
|
||||||
|
errChan := make(chan error)
|
||||||
// TODO: This need to be change. Linked to Swarm events docker/docker#23827
|
// TODO: This need to be change. Linked to Swarm events docker/docker#23827
|
||||||
ticker := time.NewTicker(SwarmDefaultWatchTime)
|
ticker := time.NewTicker(SwarmDefaultWatchTime)
|
||||||
pool.Go(func(stop chan bool) {
|
pool.Go(func(stop chan bool) {
|
||||||
|
defer close(errChan)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
services, err := p.listServices(ctx, dockerClient)
|
services, err := p.listServices(ctx, dockerClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to list services for docker, error %s", err)
|
log.Errorf("Failed to list services for docker, error %s", err)
|
||||||
|
errChan <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
configuration := p.loadDockerConfig(services)
|
configuration := p.loadDockerConfig(services)
|
||||||
|
@ -179,6 +182,10 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if err, ok := <-errChan; ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// channel closed
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
pool.Go(func(stop chan bool) {
|
pool.Go(func(stop chan bool) {
|
||||||
|
|
Loading…
Reference in a new issue