Commit 6aaea40
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
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
540 | | - | |
| 540 | + | |
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
| |||
0 commit comments