buildah icon indicating copy to clipboard operation
buildah copied to clipboard

allow using buildah via qemu and binfmt form arm 32 platforms

Open ghost opened this issue 3 years ago • 7 comments

Using buildah via qemu and binfmt ends up in failure....

level=error msg="failure getting variant" error="getCPUInfo for pattern: Cpu architecture: not found" level=error msg="error parsing PID "": strconv.Atoi: parsing "": invalid syntax"

The procedure is basically the mutiarch qemu-user-static guide, using podman to run containers and within the container run buildah with chroot and vfs https://github.com/multiarch/qemu-user-static

Setting manually --platform --arch or --variant do not help

This happens because /proc/cpuinfo remains with the original values of the main kernel (for example, intel CPU info)

One alternative could be to fail gracefully, and have the architecture variant value undefined, rather than exit the program. Another one is using the GOARM value https://zchee.github.io/golang-wiki/GoArm/ Another one being able to fully override that detection with an argument

ghost avatar Nov 20 '21 11:11 ghost

Please give us buildah info, as well as the exact command that y9ou were executing when you saw the failure.

rhatdan avatar Nov 22 '21 13:11 rhatdan

You request is irrelevant, it is a problem that can be checked on the code directly

ghost avatar Nov 29 '21 21:11 ghost

Well give me a repeater.

rhatdan avatar Nov 29 '21 22:11 rhatdan

Or open a PR to fix the code.

rhatdan avatar Nov 29 '21 22:11 rhatdan

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Dec 30 '21 00:12 github-actions[bot]

@malikumaliku I think i understand problem a bit you are trying to run arm32 binary on x86 using binfmt_misc right ? as @rhatdan suggested simple reproducer script would be helpful but could you try things below.

We are sharing code from containerd so we might have to patch containerd.

Could you please try following diff on buildah and confirm ?

diff --git a/vendor/github.com/containerd/containerd/platforms/cpuinfo.go b/vendor/github.com/containerd/containerd/platforms/cpuinfo.go
index 4a7177e3..9cc6b0d3 100644
--- a/vendor/github.com/containerd/containerd/platforms/cpuinfo.go
+++ b/vendor/github.com/containerd/containerd/platforms/cpuinfo.go
@@ -97,8 +97,7 @@ func getCPUVariant() string {
 
        variant, err := getCPUInfo("Cpu architecture")
        if err != nil {
-               log.L.WithError(err).Error("failure getting variant")
-               return ""
+               return "unknown"
        }
 
        // handle edge case for Raspberry Pi ARMv6 devices (which due to a kernel quirk, report "CPU architecture: 7")

After applying diff you would need to do a

make clean # to clean vendor
make

flouthoc avatar Dec 30 '21 08:12 flouthoc

cc @nalind just for info.

flouthoc avatar Jan 06 '22 16:01 flouthoc

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Nov 23 '22 00:11 github-actions[bot]

Closing this since there was no reply on the ticket and author id is deleted.

flouthoc avatar Nov 23 '22 00:11 flouthoc