Skip to content

Commit

Permalink
Merge pull request #5148 from wzshiming/fix/defer-cleanup
Browse files Browse the repository at this point in the history
runtime/v2: Fix defer cleanup for TaskManager.Create
  • Loading branch information
mxpv committed Mar 20, 2021
2 parents 6150170 + 30e1e66 commit 56f17a0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions runtime/v2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit 56f17a0

Please sign in to comment.