runtime: ignore ttrpc.ErrClosed when delete task

For some reason, shimv2 process doesn't exist. The ttrpc doesn't detect
the connection closed by server until delete task. For this case, we
should ignore the ttrpc.ErrClosed and let task manager handle the
cleanup.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu 2020-04-20 22:42:53 +08:00
parent 5bfab78acd
commit 0116352e1b

View File

@ -226,11 +226,14 @@ func (s *shim) Delete(ctx context.Context) (*runtime.Exit, error) {
ID: s.ID(), ID: s.ID(),
}) })
if shimErr != nil { if shimErr != nil {
log.G(ctx).WithField("id", s.ID()).WithError(shimErr).Debug("failed to delete task")
if errors.Cause(shimErr) != ttrpc.ErrClosed {
shimErr = errdefs.FromGRPC(shimErr) shimErr = errdefs.FromGRPC(shimErr)
if !errdefs.IsNotFound(shimErr) { if !errdefs.IsNotFound(shimErr) {
return nil, shimErr return nil, shimErr
} }
} }
}
// remove self from the runtime task list // remove self from the runtime task list
// this seems dirty but it cleans up the API across runtimes, tasks, and the service // this seems dirty but it cleans up the API across runtimes, tasks, and the service
s.rtTasks.Delete(ctx, s.ID()) s.rtTasks.Delete(ctx, s.ID())