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 <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2018-03-22 15:35:09 -07:00
parent 9304193b8c
commit 9754696ff5
No known key found for this signature in database
GPG Key ID: 67B3DED84EDC823F

View File

@ -163,7 +163,10 @@ func (e *execProcess) start(ctx context.Context) (err error) {
return e.parent.runtimeError(err, "OCI runtime exec failed") return e.parent.runtimeError(err, "OCI runtime exec failed")
} }
if e.stdio.Stdin != "" { 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 { if err != nil {
return errors.Wrapf(err, "failed to open stdin fifo %s", e.stdio.Stdin) 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") return errors.Wrap(err, "failed to start console copy")
} }
} else if !e.stdio.IsNull() { } else if !e.stdio.IsNull() {
if err := copyPipes(ctx, e.io, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, &copyWaitGroup); 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, &copyWaitGroup); err != nil {
return errors.Wrap(err, "failed to start io pipe copy") return errors.Wrap(err, "failed to start io pipe copy")
} }
} }