Call start in containerd

This fixes a sync issue when the containerd api returns after a
container has started.  It fixes it by calling the runtime start inside
containerd after the oom handler has been setup.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-06-24 12:02:53 -07:00
parent 14e79494da
commit 654c537d38
6 changed files with 54 additions and 30 deletions

View file

@ -260,8 +260,33 @@ func (p *process) Signal(s os.Signal) error {
// This should only be called on the process with ID "init"
func (p *process) Start() error {
if p.ID() == InitProcessID {
_, err := fmt.Fprintf(p.controlPipe, "%d %d %d\n", 2, 0, 0)
return err
var (
errC = make(chan error, 1)
shimExit = make(chan struct{}, 1)
args = append(p.container.runtimeArgs, "start", p.container.id)
cmd = exec.Command(p.container.runtime, args...)
)
go func() {
out, err := cmd.CombinedOutput()
if err != nil {
errC <- fmt.Errorf("%s: %q", err.Error(), out)
}
errC <- nil
}()
go func() {
p.Wait()
close(shimExit)
}()
select {
case err := <-errC:
if err != nil {
return err
}
case <-shimExit:
cmd.Process.Kill()
cmd.Wait()
return ErrShimExited
}
}
return nil
}