woodpecker-ci / woodpecker

Woodpecker is a simple, yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
4.2k stars 364 forks source link

Non-arm plugin-git is pulled when using next #1443

Closed danog closed 1 year ago

danog commented 1 year ago

Component

agent

Describe the bug

All builds are failing because for some reason a non-arm version of plugin-git is pulled on my arm64 machine:

exec /bin/plugin-git: exec format error

System Info

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"next-dfd4622b"}

Additional context

No response

Validations

6543 commented 1 year ago

hmm can you test if this still is the case if you pull and run it manually ?

danog commented 1 year ago

Yep, the latest tag is still broken on my pi4:

[daniil@pi4 home.daniil.it]$ docker pull docker.io/woodpeckerci/plugin-git:latest
latest: Pulling from woodpeckerci/plugin-git
Digest: sha256:883677218ecb0599f55347a87526bdef44c6d5684c9c800001d56aab15ee4c19
Status: Image is up to date for woodpeckerci/plugin-git:latest
docker.io/woodpeckerci/plugin-git:latest
[daniil@pi4 home.daniil.it]$ docker run --rm -it docker.io/woodpeckerci/plugin-git:latest
exec /bin/plugin-git: exec format error
danog commented 1 year ago

More details: builds on arm64 are broken because the arm64 latest, 2.*, v1.6.1 and next tags of https://hub.docker.com all contain x86_64 executables.

For example (example sha taken from https://hub.docker.com/layers/woodpeckerci/plugin-git/latest/images/sha256-014a6e296eb573e06179841bdd09d0888f1993602ddcf5f8d2cfbe9933c54f23?context=explore), same result with img=woodpeckerci/plugin-git:latest

img=woodpeckerci/plugin-git@sha256:014a6e296eb573e06179841bdd09d0888f1993602ddcf5f8d2cfbe9933c54f23
docker pull --platform linux/arm64 $img && docker export $(docker create $img) | tar -x && file bin/plugin-git

Result:

bin/plugin-git: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=SocNPx-xVnJaWH3SXQm8/YeNxHOfgXcmgEmH5w_0P/6_-qnapFoT7e-0x7VgVV/dMC7aku4xrgzcX6-fppX, stripped
danog commented 1 year ago

Any update on this? It should be a really simple fix, just re-building and pushing the woodpeckerci/plugin-git latest tag.

danog commented 1 year ago

Turns out I actually forgot I was force-pulling the master tag of the git plugin from my woodpecker job yaml, however docker hub still has x86 images tagged as arm64, this should really be fixed :)

arnopensource commented 1 year ago

Here is a way to demonstrate the bug (on linux/amd64)

docker pull woodpeckerci/plugin-git --platform linux/arm/v7
docker create --name plugin-git-arm woodpeckerci/plugin-git
docker cp plugin-git-arm:/bin/plugin-git .
file plugin-git

Example run

$ docker pull woodpeckerci/plugin-git --platform linux/arm/v7

Using default tag: latest
latest: Pulling from woodpeckerci/plugin-git
810dd31423a9: Pull complete 
950f45ce9dde: Pull complete 
ad3d4bc55836: Pull complete 
abde5c80bb26: Pull complete 
Digest: sha256:883677218ecb0599f55347a87526bdef44c6d5684c9c800001d56aab15ee4c19
Status: Downloaded newer image for woodpeckerci/plugin-git:latest
docker.io/woodpeckerci/plugin-git:latest

$ docker create --name plugin-git-arm woodpeckerci/plugin-git

WARNING: The requested image's platform (linux/arm/v7) does not match the detected host platform (linux/amd64) and no specific platform was requested
919db7b7e51d34ba4df0fab77d4779582c5d8088b5e49f9969f451d71eaff877

$ docker cp plugin-git-arm:/bin/plugin-git .

$ file plugin-git

plugin-git: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=SocNPx-xVnJaWH3SXQm8/YeNxHOfgXcmgEmH5w_0P/6_-qnapFoT7e-0x7VgVV/dMC7aku4xrgzcX6-fppX, stripped
arnopensource commented 1 year ago

The issue seems to first appear with version 1.6.1 I don't know if I should open an issue in https://github.com/woodpecker-ci/plugin-git ?

danog commented 1 year ago

@6543 mind fixing this? Woodpecker is essentially unusable on arm without manual config changes.

arnopensource commented 1 year ago

@6543 I would be happy to help with the bug but I got stuck here

https://github.com/woodpecker-ci/plugin-git/issues/53

arnopensource commented 1 year ago

Found the issue !

The container was an arm one but there were undefined environment variables that caused the Makefile to default to linux/amd64 for the go build

I deleted the first 2 "ARG" lines of the Dockerfile and it seems to fix the problem. The ARG lines still exist in the Dockerfile because they were duplicated !

I tried a locally built version of the plugin and it seems to work :)

arnopensource commented 1 year ago

wow I just noticed that my first 2 comments were giving exactly the same information that @danog, sorry about that

danog commented 1 year ago

It's OK, as long as https://github.com/woodpecker-ci/plugin-git/pull/54 gets merged :)

arnopensource commented 1 year ago

If you want to try the image, you can clone my repo, checkout on arm-fix and use docker buildx build --platform linux/arm/v7 --tag woodpeckerci/plugin-git:local --output type=docker -f docker/Dockerfile.multiarch . (with the right platform) And then use woodpeckerci/plugin-git:local in .woodpecker.yml I personally built it like this on my desktop and used docker save/load to use it on my rasberry pi

danog commented 1 year ago

I worked around this without rebuilding the image by specifying the 1.5.0 tag in the job yaml: https://github.com/danog/MadelineProto/blob/stable/.woodpecker/.build.yml#L11

6543 commented 1 year ago

next plugin release planed ...

6543 commented 1 year ago

blocked by https://github.com/woodpecker-ci/plugin-git/issues/56

6543 commented 1 year ago

fixed by 7f5c3d3191350e59d43934c8c8801bc7b015a115 & 7651c7311de954b23fcf2cb8bfda0e2677c35eb3