From c011502bd1a05cf69da2c64965e9d1fa3ce40ef6 Mon Sep 17 00:00:00 2001 From: Iceber Gu Date: Thu, 16 Mar 2023 10:48:35 +0800 Subject: [PATCH] Remove cri v1alpha1 services Signed-off-by: Iceber Gu --- RELEASES.md | 2 +- pkg/cri/constants/constants.go | 2 - pkg/cri/cri.go | 2 +- pkg/cri/instrument/instrumented_service.go | 1107 -------------------- pkg/cri/sbserver/service.go | 6 - pkg/cri/sbserver/version.go | 11 - pkg/cri/server/service.go | 6 - pkg/cri/server/version.go | 11 - pkg/cri/util/alpha.go | 52 - 9 files changed, 2 insertions(+), 1197 deletions(-) delete mode 100644 pkg/cri/util/alpha.go diff --git a/RELEASES.md b/RELEASES.md index 3860eae52..a785efbfb 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -378,7 +378,7 @@ The deprecated features are shown in the following table: | Container label `containerd.io/restart.logpath` | containerd v1.5 | containerd v2.0 ✅ | Use `containerd.io/restart.loguri` label | | `cri-containerd-*.tar.gz` release bundles | containerd v1.6 | containerd v2.0 | Use `containerd-*.tar.gz` bundles | | Pulling Schema 1 images (`application/vnd.docker.distribution.manifest.v1+json`) | containerd v1.7 | containerd v2.0 | Use Schema 2 or OCI images | -| CRI `v1alpha2` | containerd v1.7 | containerd v2.0 | Use CRI `v1` | +| CRI `v1alpha2` | containerd v1.7 | containerd v2.0 ✅ | Use CRI `v1` | ### Deprecated config properties The deprecated properties in [`config.toml`](./docs/cri/config.md) are shown in the following table: diff --git a/pkg/cri/constants/constants.go b/pkg/cri/constants/constants.go index 176a0e667..2e9aa680a 100644 --- a/pkg/cri/constants/constants.go +++ b/pkg/cri/constants/constants.go @@ -21,6 +21,4 @@ const ( K8sContainerdNamespace = "k8s.io" // CRIVersion is the latest CRI version supported by the CRI plugin. CRIVersion = "v1" - // CRIVersionAlpha is the alpha version of CRI supported by the CRI plugin. - CRIVersionAlpha = "v1alpha2" ) diff --git a/pkg/cri/cri.go b/pkg/cri/cri.go index 8fa806b68..c27a53bc7 100644 --- a/pkg/cri/cri.go +++ b/pkg/cri/cri.go @@ -56,7 +56,7 @@ func init() { func initCRIService(ic *plugin.InitContext) (interface{}, error) { ic.Meta.Platforms = []imagespec.Platform{platforms.DefaultSpec()} - ic.Meta.Exports = map[string]string{"CRIVersion": constants.CRIVersion, "CRIVersionAlpha": constants.CRIVersionAlpha} + ic.Meta.Exports = map[string]string{"CRIVersion": constants.CRIVersion} ctx := ic.Context pluginConfig := ic.Config.(*criconfig.PluginConfig) if err := criconfig.ValidatePluginConfig(ctx, pluginConfig); err != nil { diff --git a/pkg/cri/instrument/instrumented_service.go b/pkg/cri/instrument/instrumented_service.go index b259a86ed..4fd0de443 100644 --- a/pkg/cri/instrument/instrumented_service.go +++ b/pkg/cri/instrument/instrumented_service.go @@ -22,7 +22,6 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/log" - runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "github.com/containerd/containerd/tracing" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" @@ -39,9 +38,6 @@ type criService interface { GRPCServices IsInitialized() bool - - // AlphaVersion returns the runtime name, runtime version and runtime API version. - AlphaVersion(ctx context.Context, r *runtime_alpha.VersionRequest) (*runtime_alpha.VersionResponse, error) } // GRPCServices are all the grpc services provided by cri containerd. @@ -50,11 +46,6 @@ type GRPCServices interface { runtime.ImageServiceServer } -type GRPCAlphaServices interface { - runtime_alpha.RuntimeServiceServer - runtime_alpha.ImageServiceServer -} - // instrumentedService wraps service with containerd namespace and logs. type instrumentedService struct { c criService @@ -64,17 +55,6 @@ func NewService(c criService) GRPCServices { return &instrumentedService{c: c} } -// instrumentedAlphaService wraps service with containerd namespace and logs. -type instrumentedAlphaService struct { - c criService - runtime_alpha.UnimplementedRuntimeServiceServer - runtime_alpha.UnimplementedImageServiceServer -} - -func NewAlphaService(c criService) GRPCAlphaServices { - return &instrumentedAlphaService{c: c} -} - // checkInitialized returns error if the server is not fully initialized. // GRPC service request handlers should return error before server is fully // initialized. @@ -86,17 +66,6 @@ func (in *instrumentedService) checkInitialized() error { return errors.New("server is not initialized yet") } -// checkInitialized returns error if the server is not fully initialized. -// GRPC service request handlers should return error before server is fully -// initialized. -// NOTE(random-liu): All following functions MUST check initialized at the beginning. -func (in *instrumentedAlphaService) checkInitialized() error { - if in.c.IsInitialized() { - return nil - } - return errors.New("server is not initialized yet") -} - func (in *instrumentedService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandboxRequest) (res *runtime.RunPodSandboxResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -113,43 +82,6 @@ func (in *instrumentedService) RunPodSandbox(ctx context.Context, r *runtime.Run return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) RunPodSandbox(ctx context.Context, r *runtime_alpha.RunPodSandboxRequest) (res *runtime_alpha.RunPodSandboxResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Infof("RunPodSandbox for %+v", r.GetConfig().GetMetadata()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("RunPodSandbox for %+v failed, error", r.GetConfig().GetMetadata()) - } else { - log.G(ctx).Infof("RunPodSandbox for %+v returns sandbox id %q", r.GetConfig().GetMetadata(), res.GetPodSandboxId()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.RunPodSandboxRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.RunPodSandboxResponse - v1res, err = in.c.RunPodSandbox(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.RunPodSandboxResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("RunPodSandbox for %+v failed, error", r.GetConfig().GetMetadata()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) ListPodSandbox(ctx context.Context, r *runtime.ListPodSandboxRequest) (res *runtime.ListPodSandboxResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -166,43 +98,6 @@ func (in *instrumentedService) ListPodSandbox(ctx context.Context, r *runtime.Li return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) ListPodSandbox(ctx context.Context, r *runtime_alpha.ListPodSandboxRequest) (res *runtime_alpha.ListPodSandboxResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Tracef("ListPodSandbox with filter %+v", r.GetFilter()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Error("ListPodSandbox failed") - } else { - log.G(ctx).Tracef("ListPodSandbox returns pod sandboxes %+v", res.GetItems()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ListPodSandboxRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ListPodSandboxResponse - v1res, err = in.c.ListPodSandbox(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ListPodSandboxResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Error("ListPodSandbox failed") - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) PodSandboxStatus(ctx context.Context, r *runtime.PodSandboxStatusRequest) (res *runtime.PodSandboxStatusResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -219,43 +114,6 @@ func (in *instrumentedService) PodSandboxStatus(ctx context.Context, r *runtime. return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) PodSandboxStatus(ctx context.Context, r *runtime_alpha.PodSandboxStatusRequest) (res *runtime_alpha.PodSandboxStatusResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Tracef("PodSandboxStatus for %q", r.GetPodSandboxId()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("PodSandboxStatus for %q failed", r.GetPodSandboxId()) - } else { - log.G(ctx).Tracef("PodSandboxStatus for %q returns status %+v", r.GetPodSandboxId(), res.GetStatus()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.PodSandboxStatusRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.PodSandboxStatusResponse - v1res, err = in.c.PodSandboxStatus(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.PodSandboxStatusResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("PodSandboxStatus for %q failed", r.GetPodSandboxId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) StopPodSandbox(ctx context.Context, r *runtime.StopPodSandboxRequest) (_ *runtime.StopPodSandboxResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -272,43 +130,6 @@ func (in *instrumentedService) StopPodSandbox(ctx context.Context, r *runtime.St return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) StopPodSandbox(ctx context.Context, r *runtime_alpha.StopPodSandboxRequest) (res *runtime_alpha.StopPodSandboxResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Infof("StopPodSandbox for %q", r.GetPodSandboxId()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("StopPodSandbox for %q failed", r.GetPodSandboxId()) - } else { - log.G(ctx).Infof("StopPodSandbox for %q returns successfully", r.GetPodSandboxId()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.StopPodSandboxRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.StopPodSandboxResponse - v1res, err = in.c.StopPodSandbox(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.StopPodSandboxResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("StopPodSandbox for %q failed", r.GetPodSandboxId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) RemovePodSandbox(ctx context.Context, r *runtime.RemovePodSandboxRequest) (_ *runtime.RemovePodSandboxResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -325,43 +146,6 @@ func (in *instrumentedService) RemovePodSandbox(ctx context.Context, r *runtime. return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) RemovePodSandbox(ctx context.Context, r *runtime_alpha.RemovePodSandboxRequest) (res *runtime_alpha.RemovePodSandboxResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Infof("RemovePodSandbox for %q", r.GetPodSandboxId()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("RemovePodSandbox for %q failed", r.GetPodSandboxId()) - } else { - log.G(ctx).Infof("RemovePodSandbox %q returns successfully", r.GetPodSandboxId()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.RemovePodSandboxRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.RemovePodSandboxResponse - v1res, err = in.c.RemovePodSandbox(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.RemovePodSandboxResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("RemovePodSandbox for %q failed", r.GetPodSandboxId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) PortForward(ctx context.Context, r *runtime.PortForwardRequest) (res *runtime.PortForwardResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -378,43 +162,6 @@ func (in *instrumentedService) PortForward(ctx context.Context, r *runtime.PortF return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) PortForward(ctx context.Context, r *runtime_alpha.PortForwardRequest) (res *runtime_alpha.PortForwardResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Infof("Portforward for %q port %v", r.GetPodSandboxId(), r.GetPort()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("Portforward for %q failed", r.GetPodSandboxId()) - } else { - log.G(ctx).Infof("Portforward for %q returns URL %q", r.GetPodSandboxId(), res.GetUrl()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.PortForwardRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.PortForwardResponse - v1res, err = in.c.PortForward(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.PortForwardResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("Portforward for %q failed", r.GetPodSandboxId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) CreateContainer(ctx context.Context, r *runtime.CreateContainerRequest) (res *runtime.CreateContainerResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -434,47 +181,6 @@ func (in *instrumentedService) CreateContainer(ctx context.Context, r *runtime.C return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) CreateContainer(ctx context.Context, r *runtime_alpha.CreateContainerRequest) (res *runtime_alpha.CreateContainerResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Infof("CreateContainer within sandbox %q for container %+v", - r.GetPodSandboxId(), r.GetConfig().GetMetadata()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("CreateContainer within sandbox %q for %+v failed", - r.GetPodSandboxId(), r.GetConfig().GetMetadata()) - } else { - log.G(ctx).Infof("CreateContainer within sandbox %q for %+v returns container id %q", - r.GetPodSandboxId(), r.GetConfig().GetMetadata(), res.GetContainerId()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.CreateContainerRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.CreateContainerResponse - v1res, err = in.c.CreateContainer(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.CreateContainerResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("CreateContainer within sandbox %q for %+v failed", - r.GetPodSandboxId(), r.GetConfig().GetMetadata()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) StartContainer(ctx context.Context, r *runtime.StartContainerRequest) (_ *runtime.StartContainerResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -491,43 +197,6 @@ func (in *instrumentedService) StartContainer(ctx context.Context, r *runtime.St return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) StartContainer(ctx context.Context, r *runtime_alpha.StartContainerRequest) (res *runtime_alpha.StartContainerResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Infof("StartContainer for %q", r.GetContainerId()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("StartContainer for %q failed", r.GetContainerId()) - } else { - log.G(ctx).Infof("StartContainer for %q returns successfully", r.GetContainerId()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.StartContainerRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.StartContainerResponse - v1res, err = in.c.StartContainer(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.StartContainerResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("StartContainer for %q failed", r.GetContainerId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) ListContainers(ctx context.Context, r *runtime.ListContainersRequest) (res *runtime.ListContainersResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -545,44 +214,6 @@ func (in *instrumentedService) ListContainers(ctx context.Context, r *runtime.Li return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) ListContainers(ctx context.Context, r *runtime_alpha.ListContainersRequest) (res *runtime_alpha.ListContainersResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Tracef("ListContainers with filter %+v", r.GetFilter()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("ListContainers with filter %+v failed", r.GetFilter()) - } else { - log.G(ctx).Tracef("ListContainers with filter %+v returns containers %+v", - r.GetFilter(), res.GetContainers()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ListContainersRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ListContainersResponse - v1res, err = in.c.ListContainers(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ListContainersResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("ListContainers with filter %+v failed", r.GetFilter()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) ContainerStatus(ctx context.Context, r *runtime.ContainerStatusRequest) (res *runtime.ContainerStatusResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -599,43 +230,6 @@ func (in *instrumentedService) ContainerStatus(ctx context.Context, r *runtime.C return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) ContainerStatus(ctx context.Context, r *runtime_alpha.ContainerStatusRequest) (res *runtime_alpha.ContainerStatusResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Tracef("ContainerStatus for %q", r.GetContainerId()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("ContainerStatus for %q failed", r.GetContainerId()) - } else { - log.G(ctx).Tracef("ContainerStatus for %q returns status %+v", r.GetContainerId(), res.GetStatus()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ContainerStatusRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ContainerStatusResponse - v1res, err = in.c.ContainerStatus(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ContainerStatusResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("ContainerStatus for %q failed", r.GetContainerId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) StopContainer(ctx context.Context, r *runtime.StopContainerRequest) (res *runtime.StopContainerResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -652,43 +246,6 @@ func (in *instrumentedService) StopContainer(ctx context.Context, r *runtime.Sto return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) StopContainer(ctx context.Context, r *runtime_alpha.StopContainerRequest) (res *runtime_alpha.StopContainerResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Infof("StopContainer for %q with timeout %d (s)", r.GetContainerId(), r.GetTimeout()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("StopContainer for %q failed", r.GetContainerId()) - } else { - log.G(ctx).Infof("StopContainer for %q returns successfully", r.GetContainerId()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.StopContainerRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.StopContainerResponse - v1res, err = in.c.StopContainer(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.StopContainerResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("StopContainer for %q failed", r.GetContainerId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) RemoveContainer(ctx context.Context, r *runtime.RemoveContainerRequest) (res *runtime.RemoveContainerResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -705,43 +262,6 @@ func (in *instrumentedService) RemoveContainer(ctx context.Context, r *runtime.R return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) RemoveContainer(ctx context.Context, r *runtime_alpha.RemoveContainerRequest) (res *runtime_alpha.RemoveContainerResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Infof("RemoveContainer for %q", r.GetContainerId()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("RemoveContainer for %q failed", r.GetContainerId()) - } else { - log.G(ctx).Infof("RemoveContainer for %q returns successfully", r.GetContainerId()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.RemoveContainerRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.RemoveContainerResponse - v1res, err = in.c.RemoveContainer(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.RemoveContainerResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("RemoveContainer for %q failed", r.GetContainerId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) ExecSync(ctx context.Context, r *runtime.ExecSyncRequest) (res *runtime.ExecSyncResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -758,43 +278,6 @@ func (in *instrumentedService) ExecSync(ctx context.Context, r *runtime.ExecSync return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) ExecSync(ctx context.Context, r *runtime_alpha.ExecSyncRequest) (res *runtime_alpha.ExecSyncResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Debugf("ExecSync for %q with command %+v and timeout %d (s)", r.GetContainerId(), r.GetCmd(), r.GetTimeout()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("ExecSync for %q failed", r.GetContainerId()) - } else { - log.G(ctx).Debugf("ExecSync for %q returns with exit code %d", r.GetContainerId(), res.GetExitCode()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ExecSyncRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ExecSyncResponse - v1res, err = in.c.ExecSync(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ExecSyncResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("ExecSync for %q failed", r.GetContainerId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) Exec(ctx context.Context, r *runtime.ExecRequest) (res *runtime.ExecResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -812,44 +295,6 @@ func (in *instrumentedService) Exec(ctx context.Context, r *runtime.ExecRequest) return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) Exec(ctx context.Context, r *runtime_alpha.ExecRequest) (res *runtime_alpha.ExecResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Debugf("Exec for %q with command %+v, tty %v and stdin %v", - r.GetContainerId(), r.GetCmd(), r.GetTty(), r.GetStdin()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("Exec for %q failed", r.GetContainerId()) - } else { - log.G(ctx).Debugf("Exec for %q returns URL %q", r.GetContainerId(), res.GetUrl()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ExecRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ExecResponse - v1res, err = in.c.Exec(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ExecResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("Exec for %q failed", r.GetContainerId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) Attach(ctx context.Context, r *runtime.AttachRequest) (res *runtime.AttachResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -866,43 +311,6 @@ func (in *instrumentedService) Attach(ctx context.Context, r *runtime.AttachRequ return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) Attach(ctx context.Context, r *runtime_alpha.AttachRequest) (res *runtime_alpha.AttachResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Debugf("Attach for %q with tty %v and stdin %v", r.GetContainerId(), r.GetTty(), r.GetStdin()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("Attach for %q failed", r.GetContainerId()) - } else { - log.G(ctx).Debugf("Attach for %q returns URL %q", r.GetContainerId(), res.Url) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.AttachRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.AttachResponse - v1res, err = in.c.Attach(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.AttachResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("Attach for %q failed", r.GetContainerId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) UpdateContainerResources(ctx context.Context, r *runtime.UpdateContainerResourcesRequest) (res *runtime.UpdateContainerResourcesResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -919,43 +327,6 @@ func (in *instrumentedService) UpdateContainerResources(ctx context.Context, r * return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) UpdateContainerResources(ctx context.Context, r *runtime_alpha.UpdateContainerResourcesRequest) (res *runtime_alpha.UpdateContainerResourcesResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Infof("UpdateContainerResources for %q with Linux: %+v / Windows: %+v", r.GetContainerId(), r.GetLinux(), r.GetWindows()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("UpdateContainerResources for %q failed", r.GetContainerId()) - } else { - log.G(ctx).Infof("UpdateContainerResources for %q returns successfully", r.GetContainerId()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.UpdateContainerResourcesRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.UpdateContainerResourcesResponse - v1res, err = in.c.UpdateContainerResources(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.UpdateContainerResourcesResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("UpdateContainerResources for %q failed", r.GetContainerId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) PullImage(ctx context.Context, r *runtime.PullImageRequest) (res *runtime.PullImageResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -976,47 +347,6 @@ func (in *instrumentedService) PullImage(ctx context.Context, r *runtime.PullIma return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) PullImage(ctx context.Context, r *runtime_alpha.PullImageRequest) (res *runtime_alpha.PullImageResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - ctx, span := tracing.StartSpan(ctx, tracing.Name(criSpanPrefix, "PullImage")) - defer span.End() - log.G(ctx).Infof("PullImage %q", r.GetImage().GetImage()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("PullImage %q failed", r.GetImage().GetImage()) - } else { - log.G(ctx).Infof("PullImage %q returns image reference %q", - r.GetImage().GetImage(), res.GetImageRef()) - } - span.SetStatus(err) - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.PullImageRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.PullImageResponse - v1res, err = in.c.PullImage(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.PullImageResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("PullImage %q failed", r.GetImage().GetImage()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) ListImages(ctx context.Context, r *runtime.ListImagesRequest) (res *runtime.ListImagesResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1037,47 +367,6 @@ func (in *instrumentedService) ListImages(ctx context.Context, r *runtime.ListIm return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) ListImages(ctx context.Context, r *runtime_alpha.ListImagesRequest) (res *runtime_alpha.ListImagesResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - ctx, span := tracing.StartSpan(ctx, tracing.Name(criSpanPrefix, "ListImages")) - defer span.End() - log.G(ctx).Tracef("ListImages with filter %+v", r.GetFilter()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("ListImages with filter %+v failed", r.GetFilter()) - } else { - log.G(ctx).Tracef("ListImages with filter %+v returns image list %+v", - r.GetFilter(), res.GetImages()) - } - span.SetStatus(err) - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ListImagesRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ListImagesResponse - v1res, err = in.c.ListImages(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ListImagesResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("ListImages with filter %+v failed", r.GetFilter()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) ImageStatus(ctx context.Context, r *runtime.ImageStatusRequest) (res *runtime.ImageStatusResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1098,47 +387,6 @@ func (in *instrumentedService) ImageStatus(ctx context.Context, r *runtime.Image return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) ImageStatus(ctx context.Context, r *runtime_alpha.ImageStatusRequest) (res *runtime_alpha.ImageStatusResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - ctx, span := tracing.StartSpan(ctx, tracing.Name(criSpanPrefix, "ImageStatus")) - defer span.End() - log.G(ctx).Tracef("ImageStatus for %q", r.GetImage().GetImage()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("ImageStatus for %q failed", r.GetImage().GetImage()) - } else { - log.G(ctx).Tracef("ImageStatus for %q returns image status %+v", - r.GetImage().GetImage(), res.GetImage()) - } - span.SetStatus(err) - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ImageStatusRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ImageStatusResponse - v1res, err = in.c.ImageStatus(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ImageStatusResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("ImageStatus for %q failed", r.GetImage().GetImage()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) RemoveImage(ctx context.Context, r *runtime.RemoveImageRequest) (_ *runtime.RemoveImageResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1158,46 +406,6 @@ func (in *instrumentedService) RemoveImage(ctx context.Context, r *runtime.Remov return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) RemoveImage(ctx context.Context, r *runtime_alpha.RemoveImageRequest) (res *runtime_alpha.RemoveImageResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - ctx, span := tracing.StartSpan(ctx, tracing.Name(criSpanPrefix, "RemoveImage")) - defer span.End() - log.G(ctx).Infof("RemoveImage %q", r.GetImage().GetImage()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("RemoveImage %q failed", r.GetImage().GetImage()) - } else { - log.G(ctx).Infof("RemoveImage %q returns successfully", r.GetImage().GetImage()) - } - span.SetStatus(err) - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.RemoveImageRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.RemoveImageResponse - v1res, err = in.c.RemoveImage(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.RemoveImageResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("RemoveImage %q failed", r.GetImage().GetImage()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) ImageFsInfo(ctx context.Context, r *runtime.ImageFsInfoRequest) (res *runtime.ImageFsInfoResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1217,46 +425,6 @@ func (in *instrumentedService) ImageFsInfo(ctx context.Context, r *runtime.Image return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) ImageFsInfo(ctx context.Context, r *runtime_alpha.ImageFsInfoRequest) (res *runtime_alpha.ImageFsInfoResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - ctx, span := tracing.StartSpan(ctx, tracing.Name(criSpanPrefix, "ImageFsInfo")) - defer span.End() - log.G(ctx).Debugf("ImageFsInfo") - defer func() { - if err != nil { - log.G(ctx).WithError(err).Error("ImageFsInfo failed") - } else { - log.G(ctx).Debugf("ImageFsInfo returns filesystem info %+v", res.ImageFilesystems) - } - span.SetStatus(err) - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ImageFsInfoRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ImageFsInfoResponse - v1res, err = in.c.ImageFsInfo(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ImageFsInfoResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Error("ImageFsInfo failed") - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) PodSandboxStats(ctx context.Context, r *runtime.PodSandboxStatsRequest) (res *runtime.PodSandboxStatsResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1273,43 +441,6 @@ func (in *instrumentedService) PodSandboxStats(ctx context.Context, r *runtime.P return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) PodSandboxStats(ctx context.Context, r *runtime_alpha.PodSandboxStatsRequest) (res *runtime_alpha.PodSandboxStatsResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Debugf("PodSandboxStats for %q", r.GetPodSandboxId()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("PodSandboxStats for %q failed", r.GetPodSandboxId()) - } else { - log.G(ctx).Debugf("PodSandboxStats for %q returns stats %+v", r.GetPodSandboxId(), res.GetStats()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.PodSandboxStatsRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.PodSandboxStatsResponse - v1res, err = in.c.PodSandboxStats(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.PodSandboxStatsResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(err).Errorf("PodSandboxStats for %q failed", r.GetPodSandboxId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) ContainerStats(ctx context.Context, r *runtime.ContainerStatsRequest) (res *runtime.ContainerStatsResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1326,43 +457,6 @@ func (in *instrumentedService) ContainerStats(ctx context.Context, r *runtime.Co return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) ContainerStats(ctx context.Context, r *runtime_alpha.ContainerStatsRequest) (res *runtime_alpha.ContainerStatsResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Debugf("ContainerStats for %q", r.GetContainerId()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("ContainerStats for %q failed", r.GetContainerId()) - } else { - log.G(ctx).Debugf("ContainerStats for %q returns stats %+v", r.GetContainerId(), res.GetStats()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ContainerStatsRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ContainerStatsResponse - v1res, err = in.c.ContainerStats(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ContainerStatsResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("ContainerStats for %q failed", r.GetContainerId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) ListPodSandboxStats(ctx context.Context, r *runtime.ListPodSandboxStatsRequest) (res *runtime.ListPodSandboxStatsResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1379,43 +473,6 @@ func (in *instrumentedService) ListPodSandboxStats(ctx context.Context, r *runti return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) ListPodSandboxStats(ctx context.Context, r *runtime_alpha.ListPodSandboxStatsRequest) (res *runtime_alpha.ListPodSandboxStatsResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Tracef("ListPodSandboxStats with filter %+v", r.GetFilter()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Error("ListPodSandboxStats failed") - } else { - log.G(ctx).Tracef("ListPodSandboxStats returns stats %+v", res.GetStats()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ListPodSandboxStatsRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ListPodSandboxStatsResponse - v1res, err = in.c.ListPodSandboxStats(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ListPodSandboxStatsResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Error("ListPodSandboxStats failed") - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) ListContainerStats(ctx context.Context, r *runtime.ListContainerStatsRequest) (res *runtime.ListContainerStatsResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1432,43 +489,6 @@ func (in *instrumentedService) ListContainerStats(ctx context.Context, r *runtim return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) ListContainerStats(ctx context.Context, r *runtime_alpha.ListContainerStatsRequest) (res *runtime_alpha.ListContainerStatsResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Tracef("ListContainerStats with filter %+v", r.GetFilter()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Error("ListContainerStats failed") - } else { - log.G(ctx).Tracef("ListContainerStats returns stats %+v", res.GetStats()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ListContainerStatsRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ListContainerStatsResponse - v1res, err = in.c.ListContainerStats(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ListContainerStatsResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Error("ListContainerStats failed") - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) Status(ctx context.Context, r *runtime.StatusRequest) (res *runtime.StatusResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1485,43 +505,6 @@ func (in *instrumentedService) Status(ctx context.Context, r *runtime.StatusRequ return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) Status(ctx context.Context, r *runtime_alpha.StatusRequest) (res *runtime_alpha.StatusResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Tracef("Status") - defer func() { - if err != nil { - log.G(ctx).WithError(err).Error("Status failed") - } else { - log.G(ctx).Tracef("Status returns status %+v", res.GetStatus()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.StatusRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.StatusResponse - v1res, err = in.c.Status(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.StatusResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Error("Status failed") - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) Version(ctx context.Context, r *runtime.VersionRequest) (res *runtime.VersionResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1538,22 +521,6 @@ func (in *instrumentedService) Version(ctx context.Context, r *runtime.VersionRe return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) Version(ctx context.Context, r *runtime_alpha.VersionRequest) (res *runtime_alpha.VersionResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Tracef("Version with client side version %q", r.GetVersion()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Error("Version failed") - } else { - log.G(ctx).Tracef("Version returns %+v", res) - } - }() - res, err = in.c.AlphaVersion(ctrdutil.WithNamespace(ctx), r) - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) UpdateRuntimeConfig(ctx context.Context, r *runtime.UpdateRuntimeConfigRequest) (res *runtime.UpdateRuntimeConfigResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1570,43 +537,6 @@ func (in *instrumentedService) UpdateRuntimeConfig(ctx context.Context, r *runti return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) UpdateRuntimeConfig(ctx context.Context, r *runtime_alpha.UpdateRuntimeConfigRequest) (res *runtime_alpha.UpdateRuntimeConfigResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Debugf("UpdateRuntimeConfig with config %+v", r.GetRuntimeConfig()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Error("UpdateRuntimeConfig failed") - } else { - log.G(ctx).Debug("UpdateRuntimeConfig returns successfully") - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.UpdateRuntimeConfigRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.UpdateRuntimeConfigResponse - v1res, err = in.c.UpdateRuntimeConfig(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.UpdateRuntimeConfigResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Error("UpdateRuntimeConfig failed") - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) ReopenContainerLog(ctx context.Context, r *runtime.ReopenContainerLogRequest) (res *runtime.ReopenContainerLogResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err @@ -1623,43 +553,6 @@ func (in *instrumentedService) ReopenContainerLog(ctx context.Context, r *runtim return res, errdefs.ToGRPC(err) } -func (in *instrumentedAlphaService) ReopenContainerLog(ctx context.Context, r *runtime_alpha.ReopenContainerLogRequest) (res *runtime_alpha.ReopenContainerLogResponse, err error) { - if err := in.checkInitialized(); err != nil { - return nil, err - } - log.G(ctx).Debugf("ReopenContainerLog for %q", r.GetContainerId()) - defer func() { - if err != nil { - log.G(ctx).WithError(err).Errorf("ReopenContainerLog for %q failed", r.GetContainerId()) - } else { - log.G(ctx).Debugf("ReopenContainerLog for %q returns successfully", r.GetContainerId()) - } - }() - // converts request and response for earlier CRI version to call and get response from the current version - var v1r runtime.ReopenContainerLogRequest - if err := ctrdutil.AlphaReqToV1Req(r, &v1r); err != nil { - return nil, errdefs.ToGRPC(err) - } - var v1res *runtime.ReopenContainerLogResponse - v1res, err = in.c.ReopenContainerLog(ctrdutil.WithNamespace(ctx), &v1r) - if v1res != nil { - resp := &runtime_alpha.ReopenContainerLogResponse{} - perr := ctrdutil.V1RespToAlphaResp(v1res, resp) - if perr == nil { - res = resp - } else { - // actual error has precidence on error returned vs parse error issues - if err == nil { - err = perr - } else { - // extra log entry if convert response parse error and request error - log.G(ctx).WithError(perr).Errorf("ReopenContainerLog for %q failed", r.GetContainerId()) - } - } - } - return res, errdefs.ToGRPC(err) -} - func (in *instrumentedService) CheckpointContainer(ctx context.Context, r *runtime.CheckpointContainerRequest) (res *runtime.CheckpointContainerResponse, err error) { if err := in.checkInitialized(); err != nil { return nil, err diff --git a/pkg/cri/sbserver/service.go b/pkg/cri/sbserver/service.go index 9154ddb6c..bff7f8913 100644 --- a/pkg/cri/sbserver/service.go +++ b/pkg/cri/sbserver/service.go @@ -36,7 +36,6 @@ import ( "github.com/containerd/containerd/pkg/kmutex" "github.com/containerd/containerd/plugin" "github.com/containerd/containerd/sandbox" - runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "github.com/containerd/go-cni" "github.com/sirupsen/logrus" "google.golang.org/grpc" @@ -341,11 +340,6 @@ func (c *criService) register(s *grpc.Server) error { instrumented := instrument.NewService(c) runtime.RegisterRuntimeServiceServer(s, instrumented) runtime.RegisterImageServiceServer(s, instrumented) - - instrumentedAlpha := instrument.NewAlphaService(c) - runtime_alpha.RegisterRuntimeServiceServer(s, instrumentedAlpha) - runtime_alpha.RegisterImageServiceServer(s, instrumentedAlpha) - return nil } diff --git a/pkg/cri/sbserver/version.go b/pkg/cri/sbserver/version.go index 59fb61bda..7ea9778f3 100644 --- a/pkg/cri/sbserver/version.go +++ b/pkg/cri/sbserver/version.go @@ -19,7 +19,6 @@ package sbserver import ( "context" - runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "github.com/containerd/containerd/version" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" @@ -42,13 +41,3 @@ func (c *criService) Version(ctx context.Context, r *runtime.VersionRequest) (*r RuntimeApiVersion: constants.CRIVersion, }, nil } - -// Version returns the runtime name, runtime version and runtime API version. -func (c *criService) AlphaVersion(ctx context.Context, r *runtime_alpha.VersionRequest) (*runtime_alpha.VersionResponse, error) { - return &runtime_alpha.VersionResponse{ - Version: kubeAPIVersion, - RuntimeName: containerName, - RuntimeVersion: version.Version, - RuntimeApiVersion: constants.CRIVersionAlpha, - }, nil -} diff --git a/pkg/cri/server/service.go b/pkg/cri/server/service.go index 1e2d7a31d..7d16eb739 100644 --- a/pkg/cri/server/service.go +++ b/pkg/cri/server/service.go @@ -33,7 +33,6 @@ import ( "github.com/containerd/containerd/pkg/cri/streaming" "github.com/containerd/containerd/pkg/kmutex" "github.com/containerd/containerd/plugin" - runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2" cni "github.com/containerd/go-cni" "github.com/sirupsen/logrus" "google.golang.org/grpc" @@ -319,11 +318,6 @@ func (c *criService) register(s *grpc.Server) error { instrumented := instrument.NewService(c) runtime.RegisterRuntimeServiceServer(s, instrumented) runtime.RegisterImageServiceServer(s, instrumented) - - instrumentedAlpha := instrument.NewAlphaService(c) - runtime_alpha.RegisterRuntimeServiceServer(s, instrumentedAlpha) - runtime_alpha.RegisterImageServiceServer(s, instrumentedAlpha) - return nil } diff --git a/pkg/cri/server/version.go b/pkg/cri/server/version.go index fce877aa7..1de600f58 100644 --- a/pkg/cri/server/version.go +++ b/pkg/cri/server/version.go @@ -19,7 +19,6 @@ package server import ( "context" - runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "github.com/containerd/containerd/version" runtime "k8s.io/cri-api/pkg/apis/runtime/v1" @@ -42,13 +41,3 @@ func (c *criService) Version(ctx context.Context, r *runtime.VersionRequest) (*r RuntimeApiVersion: constants.CRIVersion, }, nil } - -// Version returns the runtime name, runtime version and runtime API version. -func (c *criService) AlphaVersion(ctx context.Context, r *runtime_alpha.VersionRequest) (*runtime_alpha.VersionResponse, error) { - return &runtime_alpha.VersionResponse{ - Version: kubeAPIVersion, - RuntimeName: containerName, - RuntimeVersion: version.Version, - RuntimeApiVersion: constants.CRIVersionAlpha, - }, nil -} diff --git a/pkg/cri/util/alpha.go b/pkg/cri/util/alpha.go deleted file mode 100644 index 80beb6b45..000000000 --- a/pkg/cri/util/alpha.go +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright The containerd Authors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package util - -import ( - "github.com/containerd/containerd/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" -) - -func AlphaReqToV1Req( - alphar protoreflect.ProtoMessage, - v1r interface{ Unmarshal(_ []byte) error }, -) error { - p, err := proto.Marshal(alphar) - if err != nil { - return err - } - - if err = v1r.Unmarshal(p); err != nil { - return err - } - return nil -} - -func V1RespToAlphaResp( - v1res interface{ Marshal() ([]byte, error) }, - alphares protoreflect.ProtoMessage, -) error { - p, err := v1res.Marshal() - if err != nil { - return err - } - - if err = proto.Unmarshal(p, alphares); err != nil { - return err - } - return nil -}