mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Wait for containerd to die before restarting it
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
4a7715c978
commit
ce160b37e1
1 changed files with 7 additions and 1 deletions
|
@ -50,6 +50,7 @@ type remote struct {
|
||||||
eventTsPath string
|
eventTsPath string
|
||||||
pastEvents map[string]*containerd.Event
|
pastEvents map[string]*containerd.Event
|
||||||
runtimeArgs []string
|
runtimeArgs []string
|
||||||
|
daemonWaitCh chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a fresh instance of libcontainerd remote.
|
// New creates a fresh instance of libcontainerd remote.
|
||||||
|
@ -129,6 +130,7 @@ func (r *remote) handleConnectionChange() {
|
||||||
transientFailureCount = 0
|
transientFailureCount = 0
|
||||||
if utils.IsProcessAlive(r.daemonPid) {
|
if utils.IsProcessAlive(r.daemonPid) {
|
||||||
utils.KillProcess(r.daemonPid)
|
utils.KillProcess(r.daemonPid)
|
||||||
|
<-r.daemonWaitCh
|
||||||
}
|
}
|
||||||
if err := r.runContainerdDaemon(); err != nil { //FIXME: Handle error
|
if err := r.runContainerdDaemon(); err != nil { //FIXME: Handle error
|
||||||
logrus.Errorf("error restarting containerd: %v", err)
|
logrus.Errorf("error restarting containerd: %v", err)
|
||||||
|
@ -388,7 +390,11 @@ func (r *remote) runContainerdDaemon() error {
|
||||||
return err
|
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
|
r.daemonPid = cmd.Process.Pid
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue