Skip to content

Commit 9754696

Browse files
committed
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 <[email protected]>
1 parent 9304193 commit 9754696

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

linux/proc/exec.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ func (e *execProcess) start(ctx context.Context) (err error) {
163163
return e.parent.runtimeError(err, "OCI runtime exec failed")
164164
}
165165
if e.stdio.Stdin != "" {
166-
sc, err := fifo.OpenFifo(ctx, e.stdio.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
166+
fifoCtx, cancel := context.WithTimeout(ctx, 15*time.Second)
167+
defer cancel()
168+
169+
sc, err := fifo.OpenFifo(fifoCtx, e.stdio.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
167170
if err != nil {
168171
return errors.Wrapf(err, "failed to open stdin fifo %s", e.stdio.Stdin)
169172
}
@@ -180,7 +183,10 @@ func (e *execProcess) start(ctx context.Context) (err error) {
180183
return errors.Wrap(err, "failed to start console copy")
181184
}
182185
} else if !e.stdio.IsNull() {
183-
if err := copyPipes(ctx, e.io, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, &copyWaitGroup); err != nil {
186+
fifoCtx, cancel := context.WithTimeout(ctx, 15*time.Second)
187+
defer cancel()
188+
189+
if err := copyPipes(fifoCtx, e.io, e.stdio.Stdin, e.stdio.Stdout, e.stdio.Stderr, &e.wg, &copyWaitGroup); err != nil {
184190
return errors.Wrap(err, "failed to start io pipe copy")
185191
}
186192
}

0 commit comments

Comments
 (0)