mirror of https://github.com/docker/docs.git
Merge pull request #23148 from mlaventure/wait-for-containerd-before-restarting-it
Wait for containerd to die before restarting it
This commit is contained in:
commit
cb36dddad1
|
|
@ -51,6 +51,7 @@ type remote struct {
|
|||
eventTsPath string
|
||||
pastEvents map[string]*containerd.Event
|
||||
runtimeArgs []string
|
||||
daemonWaitCh chan struct{}
|
||||
}
|
||||
|
||||
// New creates a fresh instance of libcontainerd remote.
|
||||
|
|
@ -130,6 +131,7 @@ func (r *remote) handleConnectionChange() {
|
|||
transientFailureCount = 0
|
||||
if utils.IsProcessAlive(r.daemonPid) {
|
||||
utils.KillProcess(r.daemonPid)
|
||||
<-r.daemonWaitCh
|
||||
}
|
||||
if err := r.runContainerdDaemon(); err != nil { //FIXME: Handle error
|
||||
logrus.Errorf("error restarting containerd: %v", err)
|
||||
|
|
@ -390,7 +392,11 @@ func (r *remote) runContainerdDaemon() error {
|
|||
return err
|
||||
}
|
||||
|
||||
go cmd.Wait() // Reap our child when needed
|
||||
r.daemonWaitCh = make(chan struct{})
|
||||
go func() {
|
||||
cmd.Wait()
|
||||
close(r.daemonWaitCh)
|
||||
}() // Reap our child when needed
|
||||
r.daemonPid = cmd.Process.Pid
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue