From b185e6e7047b59cbc5a190621031f6d6f122bded Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Thu, 10 Feb 2022 10:16:57 +0000 Subject: [PATCH] runtime: kata updates based on containerd changes Compatibility fixes with containerd updates Fixes: #3658 Signed-off-by: stevenhorsman --- src/runtime/cmd/kata-runtime/factory.go | 5 +++-- src/runtime/pkg/containerd-shim-v2/image.go | 4 ++-- src/runtime/pkg/kata-monitor/cri.go | 3 ++- src/runtime/virtcontainers/factory/grpccache/grpccache.go | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/runtime/cmd/kata-runtime/factory.go b/src/runtime/cmd/kata-runtime/factory.go index 319ff6c8a0..4049c922b2 100644 --- a/src/runtime/cmd/kata-runtime/factory.go +++ b/src/runtime/cmd/kata-runtime/factory.go @@ -24,6 +24,7 @@ import ( "github.com/urfave/cli" "golang.org/x/sys/unix" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) var factorySubCmds = []cli.Command{ @@ -235,7 +236,7 @@ var destroyFactoryCommand = cli.Command{ } if runtimeConfig.FactoryConfig.VMCacheNumber > 0 { - conn, err := grpc.Dial(fmt.Sprintf("unix://%s", runtimeConfig.FactoryConfig.VMCacheEndpoint), grpc.WithInsecure()) + conn, err := grpc.Dial(fmt.Sprintf("unix://%s", runtimeConfig.FactoryConfig.VMCacheEndpoint), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return errors.Wrapf(err, "failed to connect %q", runtimeConfig.FactoryConfig.VMCacheEndpoint) } @@ -285,7 +286,7 @@ var statusFactoryCommand = cli.Command{ } if runtimeConfig.FactoryConfig.VMCacheNumber > 0 { - conn, err := grpc.Dial(fmt.Sprintf("unix://%s", runtimeConfig.FactoryConfig.VMCacheEndpoint), grpc.WithInsecure()) + conn, err := grpc.Dial(fmt.Sprintf("unix://%s", runtimeConfig.FactoryConfig.VMCacheEndpoint), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { fmt.Fprintln(defaultOutputFile, errors.Wrapf(err, "failed to connect %q", runtimeConfig.FactoryConfig.VMCacheEndpoint)) } else { diff --git a/src/runtime/pkg/containerd-shim-v2/image.go b/src/runtime/pkg/containerd-shim-v2/image.go index 28ea7c85bf..10406995d5 100644 --- a/src/runtime/pkg/containerd-shim-v2/image.go +++ b/src/runtime/pkg/containerd-shim-v2/image.go @@ -38,8 +38,8 @@ func initImageService(ic *plugin.InitContext) (interface{}, error) { if err != nil { return nil, errors.Errorf("get task plugin error. %v", err) } - task := i.(*shim.TaskService) - s := task.Local.(*service) + task := i.(shim.TaskService) + s := task.TaskService.(*service) is := &ImageService{s: s} return is, nil } diff --git a/src/runtime/pkg/kata-monitor/cri.go b/src/runtime/pkg/kata-monitor/cri.go index f9cbf3c9fd..e973e9caf5 100644 --- a/src/runtime/pkg/kata-monitor/cri.go +++ b/src/runtime/pkg/kata-monitor/cri.go @@ -15,6 +15,7 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" pb "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" ) @@ -46,7 +47,7 @@ func getConnection(endPoint string) (*grpc.ClientConn, error) { } ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout) defer cancel() - conn, err = grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithContextDialer(dialer)) + conn, err = grpc.DialContext(ctx, addr, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock(), grpc.WithContextDialer(dialer)) if err != nil { errMsg := errors.Wrapf(err, "connect endpoint '%s', make sure you are running as root and the endpoint has been started", endPoint) return nil, errMsg diff --git a/src/runtime/virtcontainers/factory/grpccache/grpccache.go b/src/runtime/virtcontainers/factory/grpccache/grpccache.go index 71541ba0b2..5c396d94f2 100644 --- a/src/runtime/virtcontainers/factory/grpccache/grpccache.go +++ b/src/runtime/virtcontainers/factory/grpccache/grpccache.go @@ -16,6 +16,7 @@ import ( "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/factory/base" "github.com/pkg/errors" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) type grpccache struct { @@ -25,7 +26,7 @@ type grpccache struct { // New returns a new direct vm factory. func New(ctx context.Context, endpoint string) (base.FactoryBase, error) { - conn, err := grpc.Dial(fmt.Sprintf("unix://%s", endpoint), grpc.WithInsecure()) + conn, err := grpc.Dial(fmt.Sprintf("unix://%s", endpoint), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return nil, errors.Wrapf(err, "failed to connect %q", endpoint) }