8000 Merge pull request #38383 from tonistiigi/exec-ctx · moby/moby@8422e6f · GitHub
[go: up one dir, main page]

Skip to content

Commit 8422e6f

Browse files
authored
Merge pull request #38383 from tonistiigi/exec-ctx
libcontainerd: prevent exec delete locking
2 parents efba5f8 + 332f134 commit 8422e6f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libcontainerd/client_daemon.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"github.com/containerd/typeurl"
3030
"github.com/docker/docker/errdefs"
3131
"github.com/docker/docker/pkg/ioutils"
32-
"github.com/opencontainers/image-spec/specs-go/v1"
32+
v1 "github.com/opencontainers/image-spec/specs-go/v1"
3333
specs "github.com/opencontainers/runtime-spec/specs-go"
3434
"github.com/pkg/errors"
3535
"github.com/sirupsen/logrus"
@@ -384,7 +384,12 @@ func (c *client) Exec(ctx context.Context, containerID, processID string, spec *
384384
defer close(stdinCloseSync)
385385

386386
if err = p.Start(ctx); err != nil {
387-
p.Delete(context.Background())
387+
// use new context for cleanup because old one may be cancelled by user, but leave a timeout to make sure
388+
// we are not waiting forever if containerd is unresponsive or to work around fifo cancelling issues in
389+
// older containerd-shim
390+
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
391+
defer cancel()
392+
p.Delete(ctx)
388393
ctr.deleteProcess(processID)
389394
return -1, wrapError(err)
390395
}

0 commit comments

Comments
 (0)
0