From 9754696ff53dd177a343615e6c6d7dbdc94e21a3 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Thu, 22 Mar 2018 15:35:09 -0700 Subject: [PATCH] linux/prox: timeout fifo creation Under certain conditions in the client, the fifo for a container may not be created. A timeout has been added to this operation to ensure the shim can recover when the client fails to open the fifos. Signed-off-by: Stephen J Day --- linux/proc/exec.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/linux/proc/exec.go b/linux/proc/exec.go index 636879da1..5fa667ae6 100644 --- a/linux/proc/exec.go +++ b/linux/proc/exec.go @@ -163,7 +163,10 @@ func (e *execProcess) start(ctx context.Context) (err error) { return e.parent.runtimeError(err, "OCI runtime exec failed") } if e.stdio.Stdin != "" { - sc, err := fifo.OpenFifo(ctx, e.stdio.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0) + fifoCtx, cancel := context.WithTimeout(ctx, 15*time.Second) + defer cancel() + + sc, err := fifo.OpenFifo(fifoCtx, e.stdio.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0) if err != nil { return errors.Wrapf(err, "failed to open stdin fifo %s", e.stdio.Stdin) } @@ -180,7 +183,10 @@ func (e *execProcess) start(ctx context.Context) (err error) { return errors.Wrap(err, "failed to start console copy") } } else if !e.stdio.IsNull() { - if err := copyPipes(ctx, e.io, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, ©WaitGroup); err != nil { + fifoCtx, cancel := context.WithTimeout(ctx, 15*time.Second) + defer cancel() + + if err := copyPipes(fifoCtx, e.io, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, ©WaitGroup); err != nil { return errors.Wrap(err, "failed to start io pipe copy") } }