diff --git a/container.go b/container.go index 4ed462a80..9eb66adef 100644 --- a/container.go +++ b/container.go @@ -221,7 +221,7 @@ func (c *container) NewTask(ctx context.Context, ioCreate IOCreation, opts ...Ne } else { response, err := c.client.TaskService().Create(ctx, request) if err != nil { - return nil, err + return nil, errdefs.FromGRPC(err) } t.pid = response.Pid } diff --git a/process.go b/process.go index 407f9b6d2..aed931eba 100644 --- a/process.go +++ b/process.go @@ -64,7 +64,7 @@ func (p *process) Start(ctx context.Context) error { p.io.Cancel() p.io.Wait() p.io.Close() - return err + return errdefs.FromGRPC(err) } p.pid = r.Pid return nil @@ -76,7 +76,7 @@ func (p *process) Kill(ctx context.Context, s syscall.Signal) error { ContainerID: p.task.id, ExecID: p.id, }) - return err + return errdefs.FromGRPC(err) } func (p *process) Wait(ctx context.Context) (uint32, error) { @@ -125,7 +125,7 @@ func (p *process) CloseIO(ctx context.Context, opts ...IOCloserOpts) error { } r.Stdin = i.Stdin _, err := p.task.client.TaskService().CloseIO(ctx, r) - return err + return errdefs.FromGRPC(err) } func (p *process) IO() IO { @@ -139,7 +139,7 @@ func (p *process) Resize(ctx context.Context, w, h uint32) error { Height: h, ExecID: p.id, }) - return err + return errdefs.FromGRPC(err) } func (p *process) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (uint32, error) { @@ -164,7 +164,7 @@ func (p *process) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (uint32 ExecID: p.id, }) if err != nil { - return UnknownExitStatus, err + return UnknownExitStatus, errdefs.FromGRPC(err) } return r.ExitStatus, nil } diff --git a/task.go b/task.go index 34418fa0c..d77cf29f3 100644 --- a/task.go +++ b/task.go @@ -145,7 +145,7 @@ func (t *task) Start(ctx context.Context) error { t.mu.Unlock() if err != nil { t.io.Close() - return err + return errdefs.FromGRPC(err) } t.pid = response.Pid return nil @@ -156,7 +156,7 @@ func (t *task) Start(ctx context.Context) error { if err != nil { t.io.Close() } - return err + return errdefs.FromGRPC(err) } func (t *task) Kill(ctx context.Context, s syscall.Signal) error { @@ -270,7 +270,7 @@ func (t *task) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (uint32, e ContainerID: t.id, }) if err != nil { - return UnknownExitStatus, err + return UnknownExitStatus, errdefs.FromGRPC(err) } return r.ExitStatus, nil } @@ -301,7 +301,7 @@ func (t *task) Exec(ctx context.Context, id string, spec *specs.Process, ioCreat i.Cancel() i.Wait() i.Close() - return nil, err + return nil, errdefs.FromGRPC(err) } return &process{ id: id, @@ -316,7 +316,7 @@ func (t *task) Pids(ctx context.Context) ([]uint32, error) { ContainerID: t.id, }) if err != nil { - return nil, err + return nil, errdefs.FromGRPC(err) } return response.Pids, nil } @@ -331,7 +331,7 @@ func (t *task) CloseIO(ctx context.Context, opts ...IOCloserOpts) error { } r.Stdin = i.Stdin _, err := t.client.TaskService().CloseIO(ctx, r) - return err + return errdefs.FromGRPC(err) } func (t *task) IO() IO { @@ -344,7 +344,7 @@ func (t *task) Resize(ctx context.Context, w, h uint32) error { Width: w, Height: h, }) - return err + return errdefs.FromGRPC(err) } func (t *task) Checkpoint(ctx context.Context, opts ...CheckpointTaskOpts) (d v1.Descriptor, err error) { @@ -416,13 +416,13 @@ func (t *task) Update(ctx context.Context, opts ...UpdateTaskOpts) error { request.Resources = any } _, err := t.client.TaskService().Update(ctx, request) - return err + return errdefs.FromGRPC(err) } func (t *task) checkpointTask(ctx context.Context, index *v1.Index, request *tasks.CheckpointTaskRequest) error { response, err := t.client.TaskService().Checkpoint(ctx, request) if err != nil { - return err + return errdefs.FromGRPC(err) } // add the checkpoint descriptors to the index for _, d := range response.Descriptors {