Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Use buffered chan to avoid losing docker events
Browse files Browse the repository at this point in the history
Docker imposes a limit that events have to be retrieved within 100ms
or they are dropped on the sending side. Adding buffer space within
the Weave Net process allows those events to be collected from Docker
more quickly.

1024 is an arbitrary number, much higher than we expect to need.
  • Loading branch information
bboreham committed Sep 30, 2019
1 parent 9971fc3 commit ee47f0c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion common/docker/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ func (c *Client) AddObserver(ob ContainerObserver) error {
pending := make(pendingStarts)
retryInterval := InitialInterval
for {
events := make(chan *docker.APIEvents)
// Use a buffered chan so the client library can run ahead of the listener
// - Docker will drop an event if it is not collected quickly enough.
events := make(chan *docker.APIEvents, 1024)
if err := c.AddEventListener(events); err != nil {
c.errorf("Unable to add listener to Docker API: %s - retrying in %ds", err, retryInterval/time.Second)
} else {
Expand Down

0 comments on commit ee47f0c

Please sign in to comment.