From de88e9210d88bce0ea1284eadcc4a6fd89c9a7bb Mon Sep 17 00:00:00 2001 From: David Leadbeater Date: Tue, 3 Dec 2024 02:54:41 +0000 Subject: [PATCH] Use --local=false on amd64, to workaround containerd image loading --- pkg/build/nodeimage/imageimporter.go | 12 ++++++++++-- pkg/cluster/nodeutils/util.go | 11 ++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/pkg/build/nodeimage/imageimporter.go b/pkg/build/nodeimage/imageimporter.go index 7839263fe7..540c541836 100644 --- a/pkg/build/nodeimage/imageimporter.go +++ b/pkg/build/nodeimage/imageimporter.go @@ -18,6 +18,7 @@ package nodeimage import ( "io" + "runtime" "sigs.k8s.io/kind/pkg/exec" ) @@ -53,9 +54,16 @@ func (c *containerdImporter) Pull(image, platform string) error { } func (c *containerdImporter) LoadCommand() exec.Cmd { - return c.containerCmder.Command( + var opt string + // TODO: Hack to workaround #3795. + if runtime.GOARCH == "amd64" { + opt = "--local=false" + } else { // TODO: ideally we do not need this in the future. we have fixed at least one image - "ctr", "--namespace=k8s.io", "images", "import", "--label=io.cri-containerd.pinned=pinned", "--all-platforms", "--no-unpack", "--digests", "-", + opt = "--all-platforms" + } + return c.containerCmder.Command( + "ctr", "--namespace=k8s.io", "images", "import", "--label=io.cri-containerd.pinned=pinned", opt, "--no-unpack", "--digests", "-", ) } diff --git a/pkg/cluster/nodeutils/util.go b/pkg/cluster/nodeutils/util.go index 501681a2ce..14d2f6ff89 100644 --- a/pkg/cluster/nodeutils/util.go +++ b/pkg/cluster/nodeutils/util.go @@ -21,6 +21,7 @@ import ( "encoding/json" "io" "path" + "runtime" "strings" "github.com/pelletier/go-toml" @@ -82,7 +83,15 @@ func LoadImageArchive(n nodes.Node, image io.Reader) error { if err != nil { return err } - cmd := n.Command("ctr", "--namespace=k8s.io", "images", "import", "--all-platforms", "--digests", "--snapshotter="+snapshotter, "-").SetStdin(image) + var opt string + if runtime.GOARCH == "amd64" { + // TODO: Hack to workaround #3795. + opt = "--local=false" + } else { + // Needed on e.g. ARM machines to also pull amd64 images (#2957). + opt = "--all-platforms" + } + cmd := n.Command("ctr", "--namespace=k8s.io", "images", "import", opt, "--digests", "--snapshotter="+snapshotter, "-").SetStdin(image) if err := cmd.Run(); err != nil { return errors.Wrap(err, "failed to load image") }