Merge pull request #361 from thaJeztah/19.03_backport_libcontainerd_events_wait

[19.03 backport] Sleep before restarting event processing
This commit is contained in:
Andrew Hsu 2019-09-24 11:32:35 -07:00 committed by GitHub
commit f4f8feafe7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: