Skip to content

Commit

Permalink
Return errors from Docker client.Events
Browse files Browse the repository at this point in the history
  • Loading branch information
BlakeMesdag authored and traefiker committed Jan 15, 2018
1 parent bcadd68 commit 56c0634
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions provider/docker/docker.go
Expand Up @@ -2,6 +2,7 @@ package docker

import (
"context"
"io"
"math"
"net"
"net/http"
Expand Down Expand Up @@ -237,16 +238,22 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s
}

eventsc, errc := dockerClient.Events(ctx, options)
for event := range eventsc {
if event.Action == "start" ||
event.Action == "die" ||
strings.HasPrefix(event.Action, "health_status") {
startStopHandle(event)
for {
select {
case event := <-eventsc:
if event.Action == "start" ||
event.Action == "die" ||
strings.HasPrefix(event.Action, "health_status") {
startStopHandle(event)
}
case err := <-errc:
if err == io.EOF {
log.Debug("Provider event stream closed")
}

return err
}
}
if err := <-errc; err != nil {
return err
}
}
}
return nil
Expand Down

0 comments on commit 56c0634

Please sign in to comment.