Merge pull request #3393 from lifupan/fix_deadshim

shimv2: remove the dead task from runtime task list
This commit is contained in:
Phil Estes 2019-07-08 11:42:55 -04:00 committed by GitHub
commit 2aa8780ce6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,6 +140,11 @@ func (m *TaskManager) Create(ctx context.Context, id string, opts runtime.Create
return return
} }
cleanupAfterDeadShim(context.Background(), id, ns, m.events, b) 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 { if err != nil {
return nil, err return nil, err
@ -258,6 +263,8 @@ func (m *TaskManager) loadTasks(ctx context.Context) error {
return return
} }
cleanupAfterDeadShim(context.Background(), id, ns, m.events, binaryCall) cleanupAfterDeadShim(context.Background(), id, ns, m.events, binaryCall)
// Remove self from the runtime task list.
m.tasks.Delete(ctx, id)
}) })
if err != nil { if err != nil {
cleanupAfterDeadShim(ctx, id, ns, m.events, binaryCall) cleanupAfterDeadShim(ctx, id, ns, m.events, binaryCall)