From ec8d9d3d7a126e20d0bc1f3117158e8d7ba6a44b Mon Sep 17 00:00:00 2001 From: lifupan Date: Thu, 4 Jul 2019 15:38:55 +0800 Subject: [PATCH] shimv2: remove the dead task from runtime task list When shimv2 dead, the container would be cleanup, but the corresponding runtime task still existed in runtime task lists, it should be deleted too. Signed-off-by: lifupan --- runtime/v2/manager.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runtime/v2/manager.go b/runtime/v2/manager.go index 0ef854e89..481a44033 100644 --- a/runtime/v2/manager.go +++ b/runtime/v2/manager.go @@ -140,6 +140,11 @@ func (m *TaskManager) Create(ctx context.Context, id string, opts runtime.Create return } cleanupAfterDeadShim(context.Background(), id, ns, m.events, b) + // Remove self from the runtime task list. Even though the cleanupAfterDeadShim() + // would publish taskExit event, but the shim.Delete() would always failed with ttrpc + // disconnect and there is no chance to remove this dead task from runtime task lists. + // Thus it's better to delete it here. + m.tasks.Delete(ctx, id) }) if err != nil { return nil, err @@ -258,6 +263,8 @@ func (m *TaskManager) loadTasks(ctx context.Context) error { return } cleanupAfterDeadShim(context.Background(), id, ns, m.events, binaryCall) + // Remove self from the runtime task list. + m.tasks.Delete(ctx, id) }) if err != nil { cleanupAfterDeadShim(ctx, id, ns, m.events, binaryCall)