From 5cd4ddceefa0808e694720dce68f472f2ab2f478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolcman?= Date: Wed, 9 Aug 2023 12:46:10 +0200 Subject: [PATCH] Fix raspberry pi zero cpu variant recognition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ɓukasz Stolcman --- internal/pkg/platform/platform_matcher.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/pkg/platform/platform_matcher.go b/internal/pkg/platform/platform_matcher.go index 59b1d4b9e2..b0b529c426 100644 --- a/internal/pkg/platform/platform_matcher.go +++ b/internal/pkg/platform/platform_matcher.go @@ -25,6 +25,7 @@ import ( "github.com/containers/image/v5/types" imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/sirupsen/logrus" "golang.org/x/exp/slices" ) @@ -82,9 +83,25 @@ func getCPUVariantWindows(arch string) string { func getCPUVariantArm() string { variant, err := getCPUInfo("Cpu architecture") if err != nil { + logrus.Errorf("Couldn't get cpu architecture") return "" } - // TODO handle RPi Zero mismatch (https://github.com/moby/moby/pull/36121#issuecomment-398328286) + + // handle RPi Zero variant mismatch due to wrong variant from kernel + // https://github.com/containerd/containerd/pull/4530 + // https://www.raspberrypi.org/forums/viewtopic.php?t=12614 + // https://github.com/moby/moby/pull/36121#issuecomment-398328286 + if runtime.GOARCH == "arm" && variant == "7" { + model, err := getCPUInfo("model name") + if err != nil { + logrus.Errorf("Couldn't get cpu model name, it may be the corner case where variant is 6") + return "" + } + if strings.HasPrefix(strings.ToLower(model), "armv6-compatible") { + logrus.Debugf("Detected corner case, setting cpu variant to 6") + variant = "6" + } + } switch strings.ToLower(variant) { case "8", "aarch64":