runtime: kata updates based on containerd changes

Compatibility fixes with containerd updates

Fixes: #3658

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
This commit is contained in:
stevenhorsman 2022-02-10 10:16:57 +00:00
parent 4cbcc23a55
commit b185e6e704
4 changed files with 9 additions and 6 deletions

View File

@ -24,6 +24,7 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
) )
var factorySubCmds = []cli.Command{ var factorySubCmds = []cli.Command{
@ -235,7 +236,7 @@ var destroyFactoryCommand = cli.Command{
} }
if runtimeConfig.FactoryConfig.VMCacheNumber > 0 { 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 { if err != nil {
return errors.Wrapf(err, "failed to connect %q", runtimeConfig.FactoryConfig.VMCacheEndpoint) return errors.Wrapf(err, "failed to connect %q", runtimeConfig.FactoryConfig.VMCacheEndpoint)
} }
@ -285,7 +286,7 @@ var statusFactoryCommand = cli.Command{
} }
if runtimeConfig.FactoryConfig.VMCacheNumber > 0 { 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 { if err != nil {
fmt.Fprintln(defaultOutputFile, errors.Wrapf(err, "failed to connect %q", runtimeConfig.FactoryConfig.VMCacheEndpoint)) fmt.Fprintln(defaultOutputFile, errors.Wrapf(err, "failed to connect %q", runtimeConfig.FactoryConfig.VMCacheEndpoint))
} else { } else {

View File

@ -38,8 +38,8 @@ func initImageService(ic *plugin.InitContext) (interface{}, error) {
if err != nil { if err != nil {
return nil, errors.Errorf("get task plugin error. %v", err) return nil, errors.Errorf("get task plugin error. %v", err)
} }
task := i.(*shim.TaskService) task := i.(shim.TaskService)
s := task.Local.(*service) s := task.TaskService.(*service)
is := &ImageService{s: s} is := &ImageService{s: s}
return is, nil return is, nil
} }

View File

@ -15,6 +15,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
pb "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" 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) ctx, cancel := context.WithTimeout(context.Background(), defaultTimeout)
defer cancel() 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 { if err != nil {
errMsg := errors.Wrapf(err, "connect endpoint '%s', make sure you are running as root and the endpoint has been started", endPoint) errMsg := errors.Wrapf(err, "connect endpoint '%s', make sure you are running as root and the endpoint has been started", endPoint)
return nil, errMsg return nil, errMsg

View File

@ -16,6 +16,7 @@ import (
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/factory/base" "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/factory/base"
"github.com/pkg/errors" "github.com/pkg/errors"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
) )
type grpccache struct { type grpccache struct {
@ -25,7 +26,7 @@ type grpccache struct {
// New returns a new direct vm factory. // New returns a new direct vm factory.
func New(ctx context.Context, endpoint string) (base.FactoryBase, error) { 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 { if err != nil {
return nil, errors.Wrapf(err, "failed to connect %q", endpoint) return nil, errors.Wrapf(err, "failed to connect %q", endpoint)
} }