linux, linux/shim: remove error definitions

Since we now have a common set of error definitions, mapped to existing
error codes, we no longer need the specialized error codes used for
interaction with linux processes. The main issue was that string
matching was being used to map these to useful error codes. With this
change, we use errors defined in the `errdefs` package, which map
cleanly to GRPC error codes and are recoverable on either side of the
request.

The main focus of this PR was in removin these from the shim. We may
need follow ups to ensure error codes are preserved by the `Tasks`
service.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day
2017-07-18 15:41:05 -07:00
parent 6d305c741e
commit 6d0bcd5aec
12 changed files with 82 additions and 97 deletions

View File

@@ -17,12 +17,12 @@ import (
"golang.org/x/sys/unix"
"github.com/containerd/console"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/identifiers"
"github.com/containerd/containerd/linux/runcopts"
shimapi "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/runtime"
"github.com/containerd/containerd/typeurl"
"github.com/containerd/fifo"
runc "github.com/containerd/go-runc"
@@ -388,7 +388,7 @@ func checkKillError(err error) error {
return nil
}
if strings.Contains(err.Error(), "os: process already finished") || err == unix.ESRCH {
return runtime.ErrProcessExited
return errors.Wrapf(errdefs.ErrNotFound, "process already finished")
}
return err
return errors.Wrapf(err, "unknown error after kill")
}