Merge pull request #33419 from runcom/fix-reaper-containerd
libcontainerd: fix reaper goroutine position
This commit is contained in:
commit
4f55e390c4
1 changed files with 12 additions and 5 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue