Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

gcl-cmd throws '1: set: Illegal option -o pipefail' when entrypoint is set to '/bin/bash -c' #952

Closed
tan-wei-xin-alez opened this issue Aug 5, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@tan-wei-xin-alez
Copy link

Minimal .gitlab-ci.yml illustrating the issue

---
test-job:
  image: gitlab-ci-local-test-image
  script:
    - echo 'test'

The above throws the following error

➜  gitlab-ci-local
parsing and downloads finished in 48 ms
test-job starting gitlab-ci-local-test-image:latest (test)
test-job copied to docker volumes in 605 ms
test-job > /gcl-cmd: 1: set: Illegal option -o pipefail
test-job finished in 1.36 s  FAIL 2

 FAIL  test-job
  > /gcl-cmd: 1: set: Illegal option -o pipefail
pipeline finished in 1.52 s

for the following Dockerfile

FROM python:3

ENTRYPOINT [ "/bin/bash", "-c" ]

but succeeds when the ENTRYPOINT line is removed

Expected behavior
Should succeed without an issue like below

➜  gitlab-ci-local
parsing and downloads finished in 46 ms
test-job starting gitlab-ci-local-test-image:latest (test)
test-job copied to docker volumes in 635 ms
test-job $ echo 'test'
test-job > test
test-job finished in 1.4 s

 PASS  test-job
pipeline finished in 1.55 s

Host information

➜  uname -srvmo
Linux 5.15.0-75-generic #82~20.04.1-Ubuntu SMP Wed Jun 7 19:37:37 UTC 2023 x86_64 GNU/Linux
➜  gitlab-ci-local --version
4.42.0

Additional context
Add any other context about the problem here.

@firecow
Copy link
Owner

firecow commented Aug 14, 2023

I'm getting this, when trying your example on a "real" gitlab runner

image

Have you tested this on a real gitlab runner ? @tan-wei-xin-alez

@firecow firecow added the elaborate Further elaboration is needed label Aug 14, 2023
@firecow
Copy link
Owner

firecow commented Aug 14, 2023

Here is a single file example, reproducing the issue.

---
build:
  stage: build
  script: |
    docker build -t testhest - <<EOF
      FROM python:3
      ENTRYPOINT [ "/bin/bash", "-c" ]
    EOF

test-job:
  image: testhest
  script:
    - echo 'test'

@tan-wei-xin-alez
Copy link
Author

@firecow oh that's strange, it seems to work fine when I use my repos registry

Working CI job

This is the python image I'm using

➜  ~ docker image list --filter=reference=python:3
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
python       3         a5fee9aa0e3a   3 weeks ago   1.01GB

My docker version

➜  ~ docker --version
Docker version 24.0.5, build ced0996

Dockerfile is the same as mentioned above, built and pushed it to registry with the following commands

➜  ~ docker build --file gitlab-ci-local-bug/Dockerfile --tag registry.gitlab.com/<project_name>:gitlab-ci-local-bug gitlab-ci-local-bug/
[+] Building 0.0s (5/5) FINISHED                                                                      docker:default
 => [internal] load build definition from Dockerfile                                                            0.0s
 => => transferring dockerfile: 85B                                                                             0.0s
 => [internal] load .dockerignore                                                                               0.0s
 => => transferring context: 2B                                                                                 0.0s
 => [internal] load metadata for docker.io/library/python:3                                                     0.0s
 => CACHED [1/1] FROM docker.io/library/python:3                                                                0.0s
 => exporting to image                                                                                          0.0s
 => => exporting layers                                                                                         0.0s
 => => writing image sha256:9be9e8d2a2c36ad430b3101b3f9b23ce9860f3d1bc7597b6eaad6d03fbb6083f                    0.0s
 => => naming to registry.gitlab.com/<project_name>:gitlab-ci-local-bug                                         0.0s
➜  ~ docker push registry.gitlab.com/<project_name>:gitlab-ci-local-bug
The push refers to repository [registry.gitlab.com/<project_name>]
f13cae6d5fe9: Pushed
8729b6a044ba: Pushed
5c0fbc8e3c3d: Pushed
c5f1d4dd95f0: Pushed
6a25221bdf24: Pushed
b578f477cd5d: Pushed
b298f9991a11: Pushed
c94dc8fa3d89: Pushed
gitlab-ci-local-bug: digest: sha256:7d24132ca29af0fb0eb561f38a7b1ddeb5f4196713ae771b3e67b9f850c86a5a size: 2007

Then pushed the following .gitlab-ci.yml to run the job

---

stages:
  - test

test-job:
  stage: test
  image: registry.gitlab.com/<project_name>:gitlab-ci-local-bug
  tags:
    - <runner_tag>
  script:
    - echo 'test'

Does it matter that I'm using gitlab's kubernetes executor which has runner version 16.1.0?

@firecow
Copy link
Owner

firecow commented Aug 15, 2023

Perhaps.. I'll have to investigate further on our selfhosted gitlab..

@firecow
Copy link
Owner

firecow commented Nov 21, 2023

---
build-job:
  tags: [shared-shell-executor]
  script:
    - |
      docker build -t registry.example.com/debug:${CI_PIPELINE_IID} -f - . <<EOF
      FROM python:3
      ENTRYPOINT [ "/bin/bash", "-c" ]
      EOF
    - docker push registry.example.com/debug:${CI_PIPELINE_IID}

test-job:
  tags: [shared-docker-executor]
  needs: [build-job]
  image: registry.example.com/debug:${CI_PIPELINE_IID}
  script:
    - echo "test"

image

I'm getting an error, but it's not the same as gitlab-ci-local gives, so something definently needs changed in gitlab-ci-local

@firecow firecow added bug Something isn't working and removed elaborate Further elaboration is needed labels Nov 21, 2023
@firecow
Copy link
Owner

firecow commented Dec 8, 2023

I'm using a docker-executor, you are using a kubernetes executor.
Create a feature request about supporting kubernetes executors in gitlab-ci-local

@indierodo
Copy link

Sorry if this is an obvious question, I am not very familiarized with GitLab. As my organization also uses Kubernetes executor, I cannot test this. Thanks for your time.

You are saying that the docker executor cannot read an entrypoint in a gitlab-ci yml file?

I have the following example and it throws the same error:

image:
  name: apache/airflow:latest
  entrypoint: ["/bin/sh", "-c"]

stages:
  - test

test:
  stage: test
  script:
    - echo "Running basic test"
    - airflow version
    - echo "Basic test completed"

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants