Skip to content

Commit 56f17a0

Browse files
authored
Merge pull request #5148 from wzshiming/fix/defer-cleanup
runtime/v2: Fix defer cleanup for TaskManager.Create
2 parents 6150170 + 30e1e66 commit 56f17a0

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

runtime/v2/manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"path/filepath"
2525

2626
"github.com/containerd/containerd/containers"
27+
"github.com/containerd/containerd/errdefs"
2728
"github.com/containerd/containerd/events/exchange"
2829
"github.com/containerd/containerd/log"
2930
"github.com/containerd/containerd/metadata"
@@ -155,6 +156,10 @@ func (m *TaskManager) Create(ctx context.Context, id string, opts runtime.Create
155156
defer cancel()
156157
_, errShim := shim.Delete(dctx)
157158
if errShim != nil {
159+
if errdefs.IsDeadlineExceeded(errShim) {
160+
dctx, cancel = timeout.WithContext(context.Background(), cleanupTimeout)
161+
defer cancel()
162+
}
158163
shim.Shutdown(dctx)
159164
shim.Close()
160165
}

0 commit comments

Comments
 (0)