Skip to content

Commit 1ec928a

Browse files
authored
docker: add a timeout on exec setup (#6524)
We've sometimes seen ExecCreate/Attach/Start hang, so we add a timeout here. It happens very rarely and is not consistently reproducible. It seems to happen when running the exec inside a volume. Fixes #6521 Signed-off-by: Nick Santos <[email protected]>
1 parent 0a06aa8 commit 1ec928a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

internal/docker/client.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -593,18 +593,24 @@ func (c *Cli) ExecInContainer(ctx context.Context, cID container.ID, cmd model.C
593593
return errors.Wrap(err, "ExecInContainer")
594594
}
595595

596-
execId, err := c.ContainerExecCreate(ctx, cID.String(), cfg)
596+
// We've sometimes seen ExecCreate/Attach/Start hang, so we add a timeout
597+
// here. It happens very rarely and is not consistently reproducible. It
598+
// seems to happen when running the exec inside a volume.
599+
// https://github.com/tilt-dev/tilt/issues/6521
600+
createCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
601+
defer cancel()
602+
execId, err := c.ContainerExecCreate(createCtx, cID.String(), cfg)
597603
if err != nil {
598604
return errors.Wrap(err, "ExecInContainer#create")
599605
}
600606

601-
connection, err := c.ContainerExecAttach(ctx, execId.ID, types.ExecStartCheck{Tty: true})
607+
connection, err := c.ContainerExecAttach(createCtx, execId.ID, types.ExecStartCheck{Tty: true})
602608
if err != nil {
603609
return errors.Wrap(err, "ExecInContainer#attach")
604610
}
605611
defer connection.Close()
606612

607-
err = c.ContainerExecStart(ctx, execId.ID, types.ExecStartCheck{})
613+
err = c.ContainerExecStart(createCtx, execId.ID, types.ExecStartCheck{})
608614
if err != nil {
609615
return errors.Wrap(err, "ExecInContainer#start")
610616
}

0 commit comments

Comments
 (0)