1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix supervisor healthcheck throttling

Fix default case causing the throttling to not be used.
Ensure that nil client condition is handled.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan 2018-09-04 11:00:28 -07:00
parent 6ba1e91877
commit c3e3293843
No known key found for this signature in database
GPG key ID: F58C5D0A4405ACDB

View file

@ -245,6 +245,7 @@ func (r *remote) monitorDaemon(ctx context.Context) {
}()
for {
if delay != nil {
select {
case <-ctx.Done():
r.logger.Info("stopping healthcheck following graceful shutdown")
@ -253,12 +254,17 @@ func (r *remote) monitorDaemon(ctx context.Context) {
}
return
case <-delay:
default:
}
}
if r.daemonPid == -1 {
if r.daemonWaitCh != nil {
<-r.daemonWaitCh
select {
case <-ctx.Done():
r.logger.Info("stopping containerd startup following graceful shutdown")
return
case <-r.daemonWaitCh:
}
}
os.RemoveAll(r.GRPC.Address)
@ -276,6 +282,7 @@ func (r *remote) monitorDaemon(ctx context.Context) {
}
}
if client != nil {
tctx, cancel := context.WithTimeout(ctx, healthCheckTimeout)
_, err := client.IsServing(tctx)
cancel()
@ -297,6 +304,7 @@ func (r *remote) monitorDaemon(ctx context.Context) {
delay = time.After(time.Duration(transientFailureCount) * 200 * time.Millisecond)
continue
}
}
if system.IsProcessAlive(r.daemonPid) {
r.logger.WithField("pid", r.daemonPid).Info("killing and restarting containerd")
@ -304,6 +312,7 @@ func (r *remote) monitorDaemon(ctx context.Context) {
}
client.Close()
client = nil
r.daemonPid = -1
delay = nil
transientFailureCount = 0