Merge pull request #33419 from runcom/fix-reaper-containerd

libcontainerd: fix reaper goroutine position
This commit is contained in:
Kenfe-Mickaël Laventure 2017-05-30 10:55:38 -07:00 committed by GitHub
commit 4f55e390c4

View file

@ -414,6 +414,18 @@ func (r *remote) runContainerdDaemon() error {
if err := cmd.Start(); err != nil {
return err
}
// unless strictly necessary, do not add anything in between here
// as the reaper goroutine below needs to kick in as soon as possible
// and any "return" from code paths added here will defeat the reaper
// process.
r.daemonWaitCh = make(chan struct{})
go func() {
cmd.Wait()
close(r.daemonWaitCh)
}() // Reap our child when needed
logrus.Infof("libcontainerd: new containerd process, pid: %d", cmd.Process.Pid)
if err := setOOMScore(cmd.Process.Pid, r.oomScore); err != nil {
system.KillProcess(cmd.Process.Pid)
@ -424,11 +436,6 @@ func (r *remote) runContainerdDaemon() error {
return err
}
r.daemonWaitCh = make(chan struct{})
go func() {
cmd.Wait()
close(r.daemonWaitCh)
}() // Reap our child when needed
r.daemonPid = cmd.Process.Pid
return nil
}