Skip to content

Commit 6aaea40

Browse files
committed
runtime_vm: Ignore ttrpc.ErrClosed when shutting the container down
When shutting the container down, we're dealing with the following piece of code on Kata side: https://github.com/kata-containers/runtime/blob/master/containerd-shim-v2/service.go#L785 ``` func (s *service) Shutdown(ctx context.Context, r *taskAPI.ShutdownRequest) (_ *ptypes.Empty, err error) { defer func() { err = toGRPC(err) }() s.mu.Lock() if len(s.containers) != 0 { s.mu.Unlock() return empty, nil } s.mu.Unlock() s.cancel() os.Exit(0) // This will never be called, but this is only there to make sure the // program can compile. return empty, nil } ``` The code shown above will simply stop the service, closing the ttrpc channel, raising then the "ErrClosed" error, which is returned by the Shutdown. Differently from containerd code, which simply igores the error, CRI-O propagates the error, leaving a bunch of processes behind that will never ever be closed. Here's what containerd does: https://github.com/containerd/containerd/blob/master/runtime/v2/shim.go#L194 ``` _, err := s.task.Shutdown(ctx, &task.ShutdownRequest{ ID: s.ID(), }) if err != nil && !errors.Is(err, ttrpc.ErrClosed) { return errdefs.FromGRPC(err) } ``` Knowing that, let's mimic what's been done by containerd and ignore the error in this specific case. Related: kata-containers/runtime#2719 Signed-off-by: Fabiano Fidêncio <[email protected]> (cherry picked from commit 45b778d)
1 parent 93e6ee4 commit 6aaea40

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/oci/runtime_vm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ func (r *runtimeVM) DeleteContainer(c *Container) error {
537537
return err
538538
}
539539

540-
if _, err := r.task.Shutdown(r.ctx, &task.ShutdownRequest{ID: c.ID()}); err != nil {
540+
if _, err := r.task.Shutdown(r.ctx, &task.ShutdownRequest{ID: c.ID()}); err != nil && err != ttrpc.ErrClosed {
541541
return err
542542
}
543543

0 commit comments

Comments
 (0)