@@ -138,12 +138,8 @@ func (m *TaskManager) Create(ctx context.Context, id string, opts runtime.Create
138138 b := shimBinary (ctx , bundle , opts .Runtime , m .containerdAddress , m .containerdTTRPCAddress , m .events , m .tasks )
139139 shim , err := b .Start (ctx , topts , func () {
140140 log .G (ctx ).WithField ("id" , id ).Info ("shim disconnected" )
141- _ , err := m .tasks .Get (ctx , id )
142- if err != nil {
143- // Task was never started or was already successfully deleted
144- return
145- }
146- cleanupAfterDeadShim (context .Background (), id , ns , m .events , b )
141+
142+ cleanupAfterDeadShim (context .Background (), id , ns , m .tasks , m .events , b )
147143 // Remove self from the runtime task list. Even though the cleanupAfterDeadShim()
148144 // would publish taskExit event, but the shim.Delete() would always failed with ttrpc
149145 // disconnect and there is no chance to remove this dead task from runtime task lists.
@@ -266,17 +262,13 @@ func (m *TaskManager) loadTasks(ctx context.Context) error {
266262 binaryCall := shimBinary (ctx , bundle , container .Runtime .Name , m .containerdAddress , m .containerdTTRPCAddress , m .events , m .tasks )
267263 shim , err := loadShim (ctx , bundle , m .events , m .tasks , func () {
268264 log .G (ctx ).WithField ("id" , id ).Info ("shim disconnected" )
269- _ , err := m .tasks .Get (ctx , id )
270- if err != nil {
271- // Task was never started or was already successfully deleted
272- return
273- }
274- cleanupAfterDeadShim (context .Background (), id , ns , m .events , binaryCall )
265+
266+ cleanupAfterDeadShim (context .Background (), id , ns , m .tasks , m .events , binaryCall )
275267 // Remove self from the runtime task list.
276268 m .tasks .Delete (ctx , id )
277269 })
278270 if err != nil {
279- cleanupAfterDeadShim (ctx , id , ns , m .events , binaryCall )
271+ cleanupAfterDeadShim (ctx , id , ns , m .tasks , m . events , binaryCall )
280272 continue
281273 }
282274 m .tasks .Add (ctx , shim )
0 commit comments