From 366dcc08fa798b3411527885032d318688e96564 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 17 Mar 2016 14:04:48 -0700 Subject: [PATCH] Add specific error message for missing shim Signed-off-by: Michael Crosby --- runtime/container_linux.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/runtime/container_linux.go b/runtime/container_linux.go index 29bbf54..087f606 100644 --- a/runtime/container_linux.go +++ b/runtime/container_linux.go @@ -154,13 +154,9 @@ func (c *container) Start(checkpoint string, s Stdio) (Process, error) { if err != nil { return nil, err } - if err := cmd.Start(); err != nil { + if err := c.startCmd(InitProcessID, cmd, p); err != nil { return nil, err } - if err := waitForStart(p, cmd); err != nil { - return nil, err - } - c.processes[InitProcessID] = p return p, nil } @@ -198,14 +194,26 @@ func (c *container) Exec(pid string, pspec specs.ProcessSpec, s Stdio) (pp Proce if err != nil { return nil, err } - if err := cmd.Start(); err != nil { + if err := c.startCmd(pid, cmd, p); err != nil { return nil, err } + return p, nil +} + +func (c *container) startCmd(pid string, cmd *exec.Cmd, p *process) error { + if err := cmd.Start(); err != nil { + if exErr, ok := err.(*exec.Error); ok { + if exErr.Err == exec.ErrNotFound || exErr.Err == os.ErrNotExist { + return fmt.Errorf("containerd-shim not installed on system") + } + } + return err + } if err := waitForStart(p, cmd); err != nil { - return nil, err + return err } c.processes[pid] = p - return p, nil + return nil } func (c *container) getLibctContainer() (libcontainer.Container, error) {