Return errors from Docker client.Events

This commit is contained in:
Blake Mesdag 2018-01-15 08:26:03 -05:00 committed by Traefiker
parent bcadd68904
commit 56c0634918

View file

@ -2,6 +2,7 @@ package docker
import ( import (
"context" "context"
"io"
"math" "math"
"net" "net"
"net/http" "net/http"
@ -237,18 +238,24 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s
} }
eventsc, errc := dockerClient.Events(ctx, options) eventsc, errc := dockerClient.Events(ctx, options)
for event := range eventsc { for {
select {
case event := <-eventsc:
if event.Action == "start" || if event.Action == "start" ||
event.Action == "die" || event.Action == "die" ||
strings.HasPrefix(event.Action, "health_status") { strings.HasPrefix(event.Action, "health_status") {
startStopHandle(event) startStopHandle(event)
} }
case err := <-errc:
if err == io.EOF {
log.Debug("Provider event stream closed")
} }
if err := <-errc; err != nil {
return err return err
} }
} }
} }
}
return nil return nil
} }
notify := func(err error, time time.Duration) { notify := func(err error, time time.Duration) {