services/tasks, linux: ignore shutdown tasks

Because tasks may be deleted while listing containers, we need to ignore
errors from state requests that are due to a closed error. All of these
get mapped to ErrNotFound, which can be used to filter the entries.

There may be a better fix that does a better job of keeping track of the
intended state of a backend task. The current condition of assuming that
a closed client is a shutdown task may be too naive.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2018-01-09 18:16:07 -08:00
parent 29ddd3d5fb
commit c80ca4f4a2
4 changed files with 20 additions and 10 deletions

View File

@@ -129,7 +129,7 @@ func (s *Service) Start(ctx context.Context, r *shimapi.StartRequest) (*shimapi.
defer s.mu.Unlock()
p := s.processes[r.ID]
if p == nil {
return nil, errdefs.ToGRPCf(errdefs.ErrNotFound, "process %s not found", r.ID)
return nil, errdefs.ToGRPCf(errdefs.ErrNotFound, "process %s", r.ID)
}
if err := p.Start(ctx); err != nil {
return nil, err
@@ -238,7 +238,7 @@ func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi.
defer s.mu.Unlock()
p := s.processes[r.ID]
if p == nil {
return nil, errdefs.ToGRPCf(errdefs.ErrNotFound, "process id %s not found", r.ID)
return nil, errdefs.ToGRPCf(errdefs.ErrNotFound, "process id %s", r.ID)
}
st, err := p.Status(ctx)
if err != nil {