Skip to content

Commit 449e926

Browse files
authored
Merge pull request #4054 from fuweid/cp13-4048
[release/1.3 backport] bugfix: cleanup dangling shim by brand new context
2 parents 2d8cc40 + e71c7d0 commit 449e926

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

runtime/v1/linux/runtime.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ const (
6262
configFilename = "config.json"
6363
defaultRuntime = "runc"
6464
defaultShim = "containerd-shim"
65+
66+
// cleanupTimeout is default timeout for cleanup operations
67+
cleanupTimeout = 1 * time.Minute
6568
)
6669

6770
func init() {
@@ -212,7 +215,10 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
212215
}
213216
defer func() {
214217
if err != nil {
215-
if kerr := s.KillShim(ctx); kerr != nil {
218+
deferCtx, deferCancel := context.WithTimeout(
219+
namespaces.WithNamespace(context.TODO(), namespace), cleanupTimeout)
220+
defer deferCancel()
221+
if kerr := s.KillShim(deferCtx); kerr != nil {
216222
log.G(ctx).WithError(err).Error("failed to kill shim")
217223
}
218224
}

0 commit comments

Comments
 (0)