Skip to content

Commit e7a6dda

Browse files
sipsmaestesp
authored andcommitted
runtime v2: Close platform in runc shim's Shutdown method.
Previously, the platform was closed as part of the Delete method when the process was an init for a task and there were no more tasks after its deletion. This can create problems if another task is created within the shim right after the delete runs, which results in the platform being closed but the shim continuing to run. This change moves closing the platform to the Shutdown method after the shim's context is canceled, which ensures the platform is only closed once the shim is sure its done servicing containers. Signed-off-by: Erik Sipsma <[email protected]> Signed-off-by: Phil Estes <[email protected]>
1 parent cbc39d6 commit e7a6dda

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

runtime/v2/runc/v2/service.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,11 @@ func (s *service) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (*taskAP
348348
if err != nil {
349349
return nil, errdefs.ToGRPC(err)
350350
}
351-
// if we deleted our init task, close the platform and send the task delete event
351+
// if we deleted an init task, send the task delete event
352352
if r.ExecID == "" {
353353
s.mu.Lock()
354354
delete(s.containers, r.ID)
355-
hasContainers := len(s.containers) > 0
356355
s.mu.Unlock()
357-
if s.platform != nil && !hasContainers {
358-
s.platform.Close()
359-
}
360356
s.send(&eventstypes.TaskDelete{
361357
ContainerID: container.ID,
362358
Pid: uint32(p.Pid()),
@@ -600,6 +596,11 @@ func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (*pt
600596
}
601597
s.cancel()
602598
close(s.events)
599+
600+
if s.platform != nil {
601+
s.platform.Close()
602+
}
603+
603604
return empty, nil
604605
}
605606

0 commit comments

Comments
 (0)