add a wrapper around the containerd.New call to fix and pass the proper npipe connector

Signed-off-by: Luther Monson <luther.monson@gmail.com>
pull/5361/head
Luther Monson 2022-03-29 16:16:34 -07:00
parent 1339626a5b
commit 13191da58a
3 changed files with 21 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import (
"os"
"time"
"github.com/containerd/containerd"
"github.com/k3s-io/k3s/pkg/agent/templates"
util2 "github.com/k3s-io/k3s/pkg/agent/util"
"github.com/k3s-io/k3s/pkg/cgroups"
@ -112,3 +113,12 @@ func CriConnection(ctx context.Context, address string) (*grpc.ClientConn, error
return conn, nil
}
func Client(address string) (*containerd.Client, error) {
addr, _, err := util.GetAddressAndDialer("unix://" + address)
if err != nil {
return nil, err
}
return containerd.New(addr)
}

View File

@ -9,6 +9,7 @@ import (
"os"
"time"
"github.com/containerd/containerd"
"github.com/k3s-io/k3s/pkg/agent/templates"
util2 "github.com/k3s-io/k3s/pkg/agent/util"
"github.com/k3s-io/k3s/pkg/daemons/config"
@ -88,3 +89,12 @@ func CriConnection(ctx context.Context, address string) (*grpc.ClientConn, error
return conn, nil
}
func Client(address string) (*containerd.Client, error) {
addr, _, err := util.GetAddressAndDialer(address)
if err != nil {
return nil, err
}
return containerd.New(addr)
}

View File

@ -150,7 +150,7 @@ func preloadImages(ctx context.Context, cfg *config.Node) error {
return nil
}
client, err := containerd.New(cfg.Containerd.Address)
client, err := Client(cfg.Containerd.Address)
if err != nil {
return err
}