diff options
author | Noah Fontes <noah.fontes@puppet.com> | 2021-06-22 14:17:26 -0700 |
---|---|---|
committer | Noah Fontes <noah.fontes@puppet.com> | 2021-06-23 10:54:38 -0700 |
commit | 99f9230e3fbd3b3ede5628eeeb8458175bc9c1a0 (patch) | |
tree | f7ee9015457ec1c4d4d520b2575386f422e6e4b6 /pkg/shim/service.go | |
parent | 04a81bc33664b7f7b3da0666b9296e5aaf0f63e7 (diff) |
Ensure shim propagates errors over gRPC correctly
This change wraps containerd's errdefs.ToGRPC function with one that
understands Go 1.13-style error wrapping style, which is used
pervasively throughout the shim. With this change, errors that have been
marked with, e.g., `errdefs.ErrNotFound`, will be correctly propagated
back to the containerd server.
Diffstat (limited to 'pkg/shim/service.go')
-rw-r--r-- | pkg/shim/service.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/pkg/shim/service.go b/pkg/shim/service.go index ea9a1ae10..0b41f0e72 100644 --- a/pkg/shim/service.go +++ b/pkg/shim/service.go @@ -452,10 +452,10 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (*ta } process, err := newInit(r.Bundle, filepath.Join(r.Bundle, "work"), ns, s.platform, config, &s.opts, st.Rootfs) if err != nil { - return nil, errdefs.ToGRPC(err) + return nil, errToGRPC(err) } if err := process.Create(ctx, config); err != nil { - return nil, errdefs.ToGRPC(err) + return nil, errToGRPC(err) } // Set up OOM notification on the sandbox's cgroup. This is done on @@ -544,7 +544,7 @@ func (s *service) Exec(ctx context.Context, r *taskAPI.ExecProcessRequest) (*typ Spec: r.Spec, }) if err != nil { - return nil, errdefs.ToGRPC(err) + return nil, errToGRPC(err) } s.mu.Lock() s.processes[r.ExecID] = process @@ -565,7 +565,7 @@ func (s *service) ResizePty(ctx context.Context, r *taskAPI.ResizePtyRequest) (* Height: uint16(r.Height), } if err := p.Resize(ws); err != nil { - return nil, errdefs.ToGRPC(err) + return nil, errToGRPC(err) } return empty, nil } @@ -648,7 +648,7 @@ func (s *service) Kill(ctx context.Context, r *taskAPI.KillRequest) (*types.Empt } if err := p.Kill(ctx, r.Signal, r.All); err != nil { log.L.Debugf("Kill failed: %v", err) - return nil, errdefs.ToGRPC(err) + return nil, errToGRPC(err) } log.L.Debugf("Kill succeeded") return empty, nil @@ -660,7 +660,7 @@ func (s *service) Pids(ctx context.Context, r *taskAPI.PidsRequest) (*taskAPI.Pi pids, err := s.getContainerPids(ctx, r.ID) if err != nil { - return nil, errdefs.ToGRPC(err) + return nil, errToGRPC(err) } var processes []*task.ProcessInfo for _, pid := range pids { |