summaryrefslogtreecommitdiff
path: root/libcontainerd
diff options
context:
space:
mode:
authorBrian Goff <cpuguy83@gmail.com>2019-07-12 15:29:57 -0700
committerBrian Goff <cpuguy83@gmail.com>2019-07-12 15:42:19 -0700
commit1acaf2aabe000c6101501af321969df7c0ca5413 (patch)
treeb0f429057c0e69d6f41eb1986e8ffa75498e77e6 /libcontainerd
parent2fc348022259a9fa8a2cbc3a9aa1b48117f20ad8 (diff)
downloaddocker-1acaf2aabe000c6101501af321969df7c0ca5413.tar.gz
Sleep before restarting event processing
This prevents restarting event processing in a tight loop. You can see this with the following steps: ```terminal $ containerd & $ dockerd --containerd=/run/containerd/containerd.sock & $ pkill -9 containerd ``` At this point you will be spammed with logs such as: ``` ERRO[2019-07-12T22:29:37.318761400Z] failed to get event error="rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = \"transport: Error while dialing dial unix /run/containerd/containerd.sock: connect: connection refused\"" module=libcontainerd namespace=plugins.moby ``` Without this change you can quickly end up with gigabytes of log data. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Diffstat (limited to 'libcontainerd')
-rw-r--r--libcontainerd/remote/client.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/libcontainerd/remote/client.go b/libcontainerd/remote/client.go
index 9c5b98349f..10a8a25c51 100644
--- a/libcontainerd/remote/client.go
+++ b/libcontainerd/remote/client.go
@@ -703,10 +703,16 @@ func (c *client) processEventStream(ctx context.Context, ns string) {
errStatus, ok := status.FromError(err)
if !ok || errStatus.Code() != codes.Canceled {
c.logger.WithError(err).Error("failed to get event")
- go c.processEventStream(ctx, ns)
- } else {
- c.logger.WithError(ctx.Err()).Info("stopping event stream following graceful shutdown")
+
+ // rate limit
+ select {
+ case <-time.After(time.Second):
+ go c.processEventStream(ctx, ns)
+ return
+ case <-ctx.Done():
+ }
}
+ c.logger.WithError(ctx.Err()).Info("stopping event stream following graceful shutdown")
}
return
case ev = <-eventStream: