Update errdefs to 0.3.0
Uses the new github.com/containerd/errdefs/pkg module which is intended to hold less stable utility functions separately from the stable github.com/containerd/errdefs error types. Includes temporary update to hcsshim until a release is cut there Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
@@ -26,14 +26,16 @@ import (
|
||||
|
||||
eventtypes "github.com/containerd/containerd/api/events"
|
||||
api "github.com/containerd/containerd/api/services/sandbox/v1"
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/containerd/errdefs/pkg/errgrpc"
|
||||
"github.com/containerd/log"
|
||||
"github.com/containerd/plugin"
|
||||
"github.com/containerd/plugin/registry"
|
||||
|
||||
"github.com/containerd/containerd/v2/core/events"
|
||||
"github.com/containerd/containerd/v2/core/sandbox"
|
||||
"github.com/containerd/containerd/v2/pkg/protobuf"
|
||||
"github.com/containerd/containerd/v2/plugins"
|
||||
"github.com/containerd/errdefs"
|
||||
"github.com/containerd/log"
|
||||
"github.com/containerd/plugin"
|
||||
"github.com/containerd/plugin/registry"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -105,7 +107,7 @@ func (s *controllerService) Create(ctx context.Context, req *api.ControllerCreat
|
||||
// TODO: Rootfs
|
||||
ctrl, err := s.getController(req.Sandboxer)
|
||||
if err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
return nil, errgrpc.ToGRPC(err)
|
||||
}
|
||||
var sb sandbox.Sandbox
|
||||
if req.Sandbox != nil {
|
||||
@@ -115,13 +117,13 @@ func (s *controllerService) Create(ctx context.Context, req *api.ControllerCreat
|
||||
}
|
||||
err = ctrl.Create(ctx, sb, sandbox.WithOptions(req.GetOptions()))
|
||||
if err != nil {
|
||||
return &api.ControllerCreateResponse{}, errdefs.ToGRPC(err)
|
||||
return &api.ControllerCreateResponse{}, errgrpc.ToGRPC(err)
|
||||
}
|
||||
|
||||
if err := s.publisher.Publish(ctx, "sandboxes/create", &eventtypes.SandboxCreate{
|
||||
SandboxID: req.GetSandboxID(),
|
||||
}); err != nil {
|
||||
return &api.ControllerCreateResponse{}, errdefs.ToGRPC(err)
|
||||
return &api.ControllerCreateResponse{}, errgrpc.ToGRPC(err)
|
||||
}
|
||||
|
||||
return &api.ControllerCreateResponse{
|
||||
@@ -133,17 +135,17 @@ func (s *controllerService) Start(ctx context.Context, req *api.ControllerStartR
|
||||
log.G(ctx).WithField("req", req).Debug("start sandbox")
|
||||
ctrl, err := s.getController(req.Sandboxer)
|
||||
if err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
return nil, errgrpc.ToGRPC(err)
|
||||
}
|
||||
inst, err := ctrl.Start(ctx, req.GetSandboxID())
|
||||
if err != nil {
|
||||
return &api.ControllerStartResponse{}, errdefs.ToGRPC(err)
|
||||
return &api.ControllerStartResponse{}, errgrpc.ToGRPC(err)
|
||||
}
|
||||
|
||||
if err := s.publisher.Publish(ctx, "sandboxes/start", &eventtypes.SandboxStart{
|
||||
SandboxID: req.GetSandboxID(),
|
||||
}); err != nil {
|
||||
return &api.ControllerStartResponse{}, errdefs.ToGRPC(err)
|
||||
return &api.ControllerStartResponse{}, errgrpc.ToGRPC(err)
|
||||
}
|
||||
|
||||
return &api.ControllerStartResponse{
|
||||
@@ -158,20 +160,20 @@ func (s *controllerService) Stop(ctx context.Context, req *api.ControllerStopReq
|
||||
log.G(ctx).WithField("req", req).Debug("delete sandbox")
|
||||
ctrl, err := s.getController(req.Sandboxer)
|
||||
if err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
return nil, errgrpc.ToGRPC(err)
|
||||
}
|
||||
return &api.ControllerStopResponse{}, errdefs.ToGRPC(ctrl.Stop(ctx, req.GetSandboxID(), sandbox.WithTimeout(time.Duration(req.TimeoutSecs)*time.Second)))
|
||||
return &api.ControllerStopResponse{}, errgrpc.ToGRPC(ctrl.Stop(ctx, req.GetSandboxID(), sandbox.WithTimeout(time.Duration(req.TimeoutSecs)*time.Second)))
|
||||
}
|
||||
|
||||
func (s *controllerService) Wait(ctx context.Context, req *api.ControllerWaitRequest) (*api.ControllerWaitResponse, error) {
|
||||
log.G(ctx).WithField("req", req).Debug("wait sandbox")
|
||||
ctrl, err := s.getController(req.Sandboxer)
|
||||
if err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
return nil, errgrpc.ToGRPC(err)
|
||||
}
|
||||
exitStatus, err := ctrl.Wait(ctx, req.GetSandboxID())
|
||||
if err != nil {
|
||||
return &api.ControllerWaitResponse{}, errdefs.ToGRPC(err)
|
||||
return &api.ControllerWaitResponse{}, errgrpc.ToGRPC(err)
|
||||
}
|
||||
|
||||
if err := s.publisher.Publish(ctx, "sandboxes/exit", &eventtypes.SandboxExit{
|
||||
@@ -179,7 +181,7 @@ func (s *controllerService) Wait(ctx context.Context, req *api.ControllerWaitReq
|
||||
ExitStatus: exitStatus.ExitStatus,
|
||||
ExitedAt: protobuf.ToTimestamp(exitStatus.ExitedAt),
|
||||
}); err != nil {
|
||||
return &api.ControllerWaitResponse{}, errdefs.ToGRPC(err)
|
||||
return &api.ControllerWaitResponse{}, errgrpc.ToGRPC(err)
|
||||
}
|
||||
|
||||
return &api.ControllerWaitResponse{
|
||||
@@ -192,11 +194,11 @@ func (s *controllerService) Status(ctx context.Context, req *api.ControllerStatu
|
||||
log.G(ctx).WithField("req", req).Debug("sandbox status")
|
||||
ctrl, err := s.getController(req.Sandboxer)
|
||||
if err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
return nil, errgrpc.ToGRPC(err)
|
||||
}
|
||||
cstatus, err := ctrl.Status(ctx, req.GetSandboxID(), req.GetVerbose())
|
||||
if err != nil {
|
||||
return &api.ControllerStatusResponse{}, errdefs.ToGRPC(err)
|
||||
return &api.ControllerStatusResponse{}, errgrpc.ToGRPC(err)
|
||||
}
|
||||
extra := &anypb.Any{}
|
||||
if cstatus.Extra != nil {
|
||||
@@ -220,20 +222,20 @@ func (s *controllerService) Shutdown(ctx context.Context, req *api.ControllerShu
|
||||
log.G(ctx).WithField("req", req).Debug("shutdown sandbox")
|
||||
ctrl, err := s.getController(req.Sandboxer)
|
||||
if err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
return nil, errgrpc.ToGRPC(err)
|
||||
}
|
||||
return &api.ControllerShutdownResponse{}, errdefs.ToGRPC(ctrl.Shutdown(ctx, req.GetSandboxID()))
|
||||
return &api.ControllerShutdownResponse{}, errgrpc.ToGRPC(ctrl.Shutdown(ctx, req.GetSandboxID()))
|
||||
}
|
||||
|
||||
func (s *controllerService) Metrics(ctx context.Context, req *api.ControllerMetricsRequest) (*api.ControllerMetricsResponse, error) {
|
||||
log.G(ctx).WithField("req", req).Debug("sandbox metrics")
|
||||
ctrl, err := s.getController(req.Sandboxer)
|
||||
if err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
return nil, errgrpc.ToGRPC(err)
|
||||
}
|
||||
metrics, err := ctrl.Metrics(ctx, req.GetSandboxID())
|
||||
if err != nil {
|
||||
return &api.ControllerMetricsResponse{}, errdefs.ToGRPC(err)
|
||||
return &api.ControllerMetricsResponse{}, errgrpc.ToGRPC(err)
|
||||
}
|
||||
return &api.ControllerMetricsResponse{
|
||||
Metrics: metrics,
|
||||
@@ -246,14 +248,14 @@ func (s *controllerService) Update(
|
||||
log.G(ctx).WithField("req", req).Debug("sandbox update resource")
|
||||
ctrl, err := s.getController(req.Sandboxer)
|
||||
if err != nil {
|
||||
return nil, errdefs.ToGRPC(err)
|
||||
return nil, errgrpc.ToGRPC(err)
|
||||
}
|
||||
if req.Sandbox == nil {
|
||||
return nil, fmt.Errorf("sandbox can not be nil")
|
||||
}
|
||||
err = ctrl.Update(ctx, req.SandboxID, sandbox.FromProto(req.Sandbox), req.Fields...)
|
||||
if err != nil {
|
||||
return &api.ControllerUpdateResponse{}, errdefs.ToGRPC(err)
|
||||
return &api.ControllerUpdateResponse{}, errgrpc.ToGRPC(err)
|
||||
}
|
||||
return &api.ControllerUpdateResponse{}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user