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

@@ -10,6 +10,8 @@ import (
"github.com/containerd/containerd/errdefs"
shim "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/runtime"
"github.com/pkg/errors"
"github.com/stevvooe/ttrpc"
)
// Process implements a linux process
@@ -44,7 +46,14 @@ func (p *Process) State(ctx context.Context) (runtime.State, error) {
ID: p.id,
})
if err != nil {
return runtime.State{}, errdefs.FromGRPC(err)
if errors.Cause(err) != ttrpc.ErrClosed {
return runtime.State{}, errdefs.FromGRPC(err)
}
// We treat ttrpc.ErrClosed as the shim being closed, but really this
// likely means that the process no longer exists. We'll have to plumb
// the connection differently if this causes problems.
return runtime.State{}, errdefs.ErrNotFound
}
var status runtime.Status
switch response.Status {