From f9ecd09f4f686bc4076568af817ae16601db300b Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Thu, 17 Mar 2016 23:53:23 -0700 Subject: [PATCH] Retry on pidfile read error Signed-off-by: Tonis Tiigi --- runtime/container_linux.go | 2 +- runtime/process.go | 2 +- runtime/runtime.go | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/runtime/container_linux.go b/runtime/container_linux.go index 1e4e265..5b3a65d 100644 --- a/runtime/container_linux.go +++ b/runtime/container_linux.go @@ -313,7 +313,7 @@ func (c *container) writeEventFD(root string, cfd, efd int) error { func waitForStart(p *process, cmd *exec.Cmd) error { for i := 0; i < 300; i++ { if _, err := p.getPidFromFile(); err != nil { - if os.IsNotExist(err) { + if os.IsNotExist(err) || err == errInvalidPidInt { alive, err := isAlive(cmd) if err != nil { return err diff --git a/runtime/process.go b/runtime/process.go index ff80ec5..082996e 100644 --- a/runtime/process.go +++ b/runtime/process.go @@ -199,7 +199,7 @@ func (p *process) getPidFromFile() (int, error) { } i, err := strconv.Atoi(string(data)) if err != nil { - return -1, err + return -1, errInvalidPidInt } p.pid = i return i, nil diff --git a/runtime/runtime.go b/runtime/runtime.go index 39ed404..1423c76 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -19,6 +19,7 @@ var ( ErrContainerNotStarted = errors.New("containerd: container not started") errNoPidFile = errors.New("containerd: no process pid file found") + errInvalidPidInt = errors.New("containerd: process pid is invalid") errNotImplemented = errors.New("containerd: not implemented") )