From 30e1e66e5cb11925d78bc7d6743b8789d8ac9baf Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Wed, 10 Mar 2021 18:15:26 +0800 Subject: [PATCH] runtime/v2: Fix defer cleanup Signed-off-by: Shiming Zhang --- runtime/v2/manager.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runtime/v2/manager.go b/runtime/v2/manager.go index 177b2f144..16da060bd 100644 --- a/runtime/v2/manager.go +++ b/runtime/v2/manager.go @@ -24,6 +24,7 @@ import ( "path/filepath" "github.com/containerd/containerd/containers" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events/exchange" "github.com/containerd/containerd/log" "github.com/containerd/containerd/metadata" @@ -155,6 +156,10 @@ func (m *TaskManager) Create(ctx context.Context, id string, opts runtime.Create defer cancel() _, errShim := shim.Delete(dctx) if errShim != nil { + if errdefs.IsDeadlineExceeded(errShim) { + dctx, cancel = timeout.WithContext(context.Background(), cleanupTimeout) + defer cancel() + } shim.Shutdown(dctx) shim.Close() }