From a9ae6c7547466f754da01a53c6be455c555e6102 Mon Sep 17 00:00:00 2001 From: Andrew Hsu Date: Mon, 17 Dec 2018 12:06:35 +0000 Subject: [PATCH 1/2] Revert "Propagate context to exec delete" This reverts commit b6430ba41388f0300ceea95c10738cbe1a9a7b10. Signed-off-by: Andrew Hsu --- libcontainerd/client_daemon.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcontainerd/client_daemon.go b/libcontainerd/client_daemon.go index 7937c96847fe5..cb9cb43a7316f 100644 --- a/libcontainerd/client_daemon.go +++ b/libcontainerd/client_daemon.go @@ -384,7 +384,7 @@ func (c *client) Exec(ctx context.Context, containerID, processID string, spec * defer close(stdinCloseSync) if err = p.Start(ctx); err != nil { - p.Delete(ctx) + p.Delete(context.Background()) ctr.deleteProcess(processID) return -1, wrapError(err) } From 6646d0878247b1e0875da33da606283f5d16ea07 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 17 Dec 2018 12:22:37 +0200 Subject: [PATCH 2/2] libcontainerd: prevent exec delete locking Signed-off-by: Tonis Tiigi (cherry picked from commit 332f134890246cfc73703b2911c9fdc20e063096) Signed-off-by: Andrew Hsu --- libcontainerd/client_daemon.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libcontainerd/client_daemon.go b/libcontainerd/client_daemon.go index cb9cb43a7316f..d59907c570b0a 100644 --- a/libcontainerd/client_daemon.go +++ b/libcontainerd/client_daemon.go @@ -29,7 +29,7 @@ import ( "github.com/containerd/typeurl" "github.com/docker/docker/errdefs" "github.com/docker/docker/pkg/ioutils" - "github.com/opencontainers/image-spec/specs-go/v1" + v1 "github.com/opencontainers/image-spec/specs-go/v1" specs "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -384,7 +384,12 @@ func (c *client) Exec(ctx context.Context, containerID, processID string, spec * defer close(stdinCloseSync) if err = p.Start(ctx); err != nil { - p.Delete(context.Background()) + // use new context for cleanup because old one may be cancelled by user, but leave a timeout to make sure + // we are not waiting forever if containerd is unresponsive or to work around fifo cancelling issues in + // older containerd-shim + ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second) + defer cancel() + p.Delete(ctx) ctr.deleteProcess(processID) return -1, wrapError(err) }