firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.28k stars 128 forks source link

Job fails when using quay.io/condaforge/linux-anvil-cos7-x86_64 image #1220

Closed sgaist closed 4 months ago

sgaist commented 4 months ago

Minimal .gitlab-ci.yml illustrating the issue

---
job:
  image: quay.io/condaforge/linux-anvil-cos7-x86_64
  script:
    - echo "Heya"
    - ls -la
    - python3 hello.py

hello.py:

print("Hello world")

Expected behavior

job copied to docker volumes in 3.38 s
job $ echo "Heya"
job > Heya
job $ ls -la
job > total 16
job > drwxrwxrwx 3 root root 4096 May 14 15:21 .
job > drwxr-xr-x 1 root root 4096 May 14 15:22 ..
job > drwxrwxrwx 7 root root 4096 May 14 15:11 .git
job > -rw-rw-rw- 1 root root   21 May 14 15:13 test.py
job $ python3 test.py
job > Hello world
job finished in 13 s

Actual behavior

job copied to docker volumes in 3.88 s
job > bash: cannot set terminal process group (-1): Inappropriate ioctl for device
job > bash: no job control in this shell
job $ echo "Heya"
job > Heya
job $ ls -la
job > total 24
job > drwx------ 2 conda conda 4096 May 14 15:17 .
job > drwxr-xr-x 1 root  root  4096 May 14 15:17 ..
job > -rw-r--r-- 1 conda conda   18 Nov 24  2021 .bash_logout
job > -rw-r--r-- 1 conda conda  193 Nov 24  2021 .bash_profile
job > -rw-r--r-- 1 conda conda  231 Nov 24  2021 .bashrc
job > -rw-r--r-- 1 conda conda   75 May 14 15:17 .condarc
job $ python3 test.py
job > python3: can't open file '/home/conda/hello.py': [Errno 2] No such file or directory
job finished in 7.83 s  FAIL 2

Host information KDE Neon gitlab-ci-local 4.46.1

macOS 13.6.6 gitlab-ci-local 4.49.00

Containerd binary macOS Docker Desktop with Docker version 24.0.7-rd, build 72ffacf

Linux Docker version 26.1.2, build 211e74b

Additional context The "faulty" image can be used successfully with GitLab with the docker runner. The "Expected behaviour" run uses python:3.12-slim-bookworm for the image.

Both images can be run using docker directly.

ANGkeith commented 4 months ago

hmm, a wild guess

https://github.com/firecow/gitlab-ci-local?tab=readme-ov-file#tracked-files

will ^ fix the issue

firecow commented 4 months ago

What @ANGkeith said 👍 Feel free to reopen, if git add isn't your issue.

sgaist commented 4 months ago

Sadly it's something different.

The original issue was detected with an already existing repository where all required files were added. To ensure I did not miss something for the reproducer, I did a commit with all the files before starting gitlab-ci-local.

sgaist commented 4 months ago

@firecow AFAIK, I cannot reopen the issue myself since I did not close it and I am not a collaborator on the project.

ANGkeith commented 4 months ago

Cool managed to replicate it

The "Expected behaviour" run uses python:3.12-slim-bookworm for the image.

my bad i missed this message of yours

seemed like this bug is caused by the entrypoint of the image changing the cwd

As a tempfix:

---
job:
  image: quay.io/condaforge/linux-anvil-cos7-x86_64
  script:
    - cd $CI_PROJECT_DIR # <============
    - echo "Heya"
    - ls -la
    - python3 hello.py
firecow commented 4 months ago

How does Gitlab manage to handle this CI_PROJECT_DIR swith-a-roo?

ANGkeith commented 4 months ago

without digging into the source code,

i suspect its doing the same thing under the hood

image

sgaist commented 4 months ago

Thanks !