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

@@ -4,12 +4,11 @@ package linux
import (
"context"
"errors"
"github.com/containerd/containerd/api/types/task"
"github.com/containerd/containerd/errdefs"
shim "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/runtime"
"google.golang.org/grpc"
)
type Process struct {
@@ -27,7 +26,7 @@ func (p *Process) Kill(ctx context.Context, signal uint32, _ bool) error {
ID: p.id,
})
if err != nil {
err = errors.New(grpc.ErrorDesc(err))
return errdefs.FromGRPC(err)
}
return err
}
@@ -38,7 +37,7 @@ func (p *Process) State(ctx context.Context) (runtime.State, error) {
ID: p.id,
})
if err != nil {
return runtime.State{}, errors.New(grpc.ErrorDesc(err))
return runtime.State{}, errdefs.FromGRPC(err)
}
var status runtime.Status
switch response.Status {
@@ -69,7 +68,7 @@ func (p *Process) ResizePty(ctx context.Context, size runtime.ConsoleSize) error
Height: size.Height,
})
if err != nil {
err = errors.New(grpc.ErrorDesc(err))
err = errdefs.FromGRPC(err)
}
return err
}
@@ -80,7 +79,7 @@ func (p *Process) CloseIO(ctx context.Context) error {
Stdin: true,
})
if err != nil {
err = errors.New(grpc.ErrorDesc(err))
err = errdefs.FromGRPC(err)
}
return err
}