From 13191da58a9f6dc3951eeb932e05c4ab376bcef2 Mon Sep 17 00:00:00 2001 From: Luther Monson Date: Tue, 29 Mar 2022 16:16:34 -0700 Subject: [PATCH] add a wrapper around the containerd.New call to fix and pass the proper npipe connector Signed-off-by: Luther Monson --- pkg/agent/containerd/config_linux.go | 10 ++++++++++ pkg/agent/containerd/config_windows.go | 10 ++++++++++ pkg/agent/containerd/containerd.go | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pkg/agent/containerd/config_linux.go b/pkg/agent/containerd/config_linux.go index d876b33f43..6dc2ca1b83 100644 --- a/pkg/agent/containerd/config_linux.go +++ b/pkg/agent/containerd/config_linux.go @@ -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) +} diff --git a/pkg/agent/containerd/config_windows.go b/pkg/agent/containerd/config_windows.go index 348ecd5a2f..5720cd2395 100644 --- a/pkg/agent/containerd/config_windows.go +++ b/pkg/agent/containerd/config_windows.go @@ -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) +} diff --git a/pkg/agent/containerd/containerd.go b/pkg/agent/containerd/containerd.go index b54e28a1c3..34ae97a18d 100644 --- a/pkg/agent/containerd/containerd.go +++ b/pkg/agent/containerd/containerd.go @@ -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 }