Skip to content

Commit d1d3fd0

Browse files
committed
Delete task on dead shim
Signed-off-by: Michael Crosby <[email protected]>
1 parent 04b5f3f commit d1d3fd0

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

linux/runtime.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
201201
"id": id,
202202
"namespace": namespace,
203203
}).Warn("cleaning up after killed shim")
204-
err = r.cleanupAfterDeadShim(context.Background(), bundle, namespace, id, lc.pid)
205-
if err == nil {
206-
r.tasks.Delete(ctx, lc)
207-
} else {
204+
if err = r.cleanupAfterDeadShim(context.Background(), bundle, namespace, id, lc.pid); err != nil {
208205
log.G(ctx).WithError(err).WithFields(logrus.Fields{
209206
"id": id,
210207
"namespace": namespace,
@@ -313,7 +310,7 @@ func (r *Runtime) Delete(ctx context.Context, c runtime.Task) (*runtime.Exit, er
313310
}
314311
return nil, errdefs.FromGRPC(err)
315312
}
316-
r.tasks.Delete(ctx, lc)
313+
r.tasks.Delete(ctx, lc.id)
317314
if err := lc.shim.KillShim(ctx); err != nil {
318315
log.G(ctx).WithError(err).Error("failed to kill shim")
319316
}
@@ -443,6 +440,7 @@ func (r *Runtime) cleanupAfterDeadShim(ctx context.Context, bundle *bundle, ns,
443440
ExitedAt: exitedAt,
444441
})
445442

443+
r.tasks.Delete(ctx, id)
446444
if err := bundle.Delete(); err != nil {
447445
log.G(ctx).WithError(err).Error("delete bundle")
448446
}
@@ -458,12 +456,10 @@ func (r *Runtime) cleanupAfterDeadShim(ctx context.Context, bundle *bundle, ns,
458456
}
459457

460458
func (r *Runtime) terminate(ctx context.Context, bundle *bundle, ns, id string) error {
461-
ctx = namespaces.WithNamespace(ctx, ns)
462459
rt, err := r.getRuntime(ctx, ns, id)
463460
if err != nil {
464461
return err
465462
}
466-
467463
if err := rt.Delete(ctx, id, &runc.DeleteOpts{
468464
Force: true,
469465
}); err != nil {

runtime/task_list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (l *TaskList) AddWithNamespace(namespace string, t Task) error {
9292
}
9393

9494
// Delete a task
95-
func (l *TaskList) Delete(ctx context.Context, t Task) {
95+
func (l *TaskList) Delete(ctx context.Context, id string) {
9696
l.mu.Lock()
9797
defer l.mu.Unlock()
9898
namespace, err := namespaces.NamespaceRequired(ctx)
@@ -101,6 +101,6 @@ func (l *TaskList) Delete(ctx context.Context, t Task) {
101101
}
102102
tasks, ok := l.tasks[namespace]
103103
if ok {
104-
delete(tasks, t.ID())
104+
delete(tasks, id)
105105
}
106106
}

windows/runtime.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (r *windowsRuntime) Delete(ctx context.Context, t runtime.Task) (*runtime.E
194194
}
195195

196196
wt.cleanup()
197-
r.tasks.Delete(ctx, t)
197+
r.tasks.Delete(ctx, t.ID())
198198

199199
r.publisher.Publish(ctx,
200200
runtime.TaskDeleteEventTopic,

0 commit comments

Comments
 (0)