Merge pull request #137 from docker/shim-errors
Don't treat runtime error as shim error
This commit is contained in:
commit
707555be47
2 changed files with 13 additions and 0 deletions
|
@ -31,6 +31,13 @@ func main() {
|
|||
logrus.SetOutput(f)
|
||||
logrus.SetFormatter(&logrus.JSONFormatter{})
|
||||
if err := start(); err != nil {
|
||||
// this means that the runtime failed starting the container and will have the
|
||||
// proper error messages in the runtime log so we should to treat this as a
|
||||
// shim failure because the sim executed properly
|
||||
if err == errRuntime {
|
||||
f.Close()
|
||||
return
|
||||
}
|
||||
// log the error instead of writing to stderr because the shim will have
|
||||
// /dev/null as it's stdio because it is supposed to be reparented to system
|
||||
// init and will not have anyone to read from it
|
||||
|
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -16,6 +17,8 @@ import (
|
|||
"github.com/opencontainers/runc/libcontainer"
|
||||
)
|
||||
|
||||
var errRuntime = errors.New("shim: runtime execution error")
|
||||
|
||||
type process struct {
|
||||
sync.WaitGroup
|
||||
id string
|
||||
|
@ -144,6 +147,9 @@ func (p *process) start() error {
|
|||
p.stdio.stdout.Close()
|
||||
p.stdio.stderr.Close()
|
||||
if err := cmd.Wait(); err != nil {
|
||||
if _, ok := err.(*exec.ExitError); ok {
|
||||
return errRuntime
|
||||
}
|
||||
return err
|
||||
}
|
||||
data, err := ioutil.ReadFile("pid")
|
||||
|
|
Loading…
Reference in a new issue