Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

gitlab-runner registered but throws error #2129

Closed
sevillaarvin opened this issue May 13, 2019 · 4 comments
Closed

gitlab-runner registered but throws error #2129

sevillaarvin opened this issue May 13, 2019 · 4 comments
Labels

Comments

@sevillaarvin
Copy link
Contributor

Info:

  • Docker version ($ docker --version): Docker version 18.09.6, build 481bc77
  • Laradock commit ($ git rev-parse HEAD): c7289f7
  • System info (Mac, PC, Linux) ($ uname -a): Linux *** 4.15.0-48-generic ERROR: for application argument of type 'NoneType' is not iterable #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • System info distro/version ($ lsb_release -a): elementary OS 5.0 Juno

Issue:

gitlab-runner throws an error during job execution


Expected behavior:

gitlab-runner to run successfully


Reproduce:

  1. Start gitlab and retrieve runner registration token
    docker-compose up -d gitlab
  2. Modify .env file*
GITLAB_CI_SERVER_URL=http://gitlab
GITLAB_RUNNER_REGISTRATION_TOKEN=uQ2xyYTUDVVDtRgLxNzz
  1. Modify docker-compose.yml (add networks: tag in gitlab-runner)*
    gitlab-runner:
      image: gitlab/gitlab-runner:latest
      environment:
        - CI_SERVER_URL=${GITLAB_CI_SERVER_URL}
        - REGISTRATION_TOKEN=${GITLAB_RUNNER_REGISTRATION_TOKEN}
        - RUNNER_NAME=${COMPOSE_PROJECT_NAME}-runner
        - REGISTER_NON_INTERACTIVE=${GITLAB_REGISTER_NON_INTERACTIVE}
        - RUNNER_EXECUTOR=shell
      volumes:
        - ${DATA_PATH_HOST}/gitlab/runner:/etc/gitlab-runner
        - /var/run/docker.sock:/var/run/docker.sock:rw
      networks:
        - backend
  1. Start gitlab-runner
    docker-compose up -d gitlab gitlab-runner
  2. Register gitlab-runner
docker-compose exec gitlab-runner bash
gitlab-runner register
  1. Confirm registration at Settings > CI / CD > Runners
  2. Push code with the following .gitlab-ci.yml (Test script per https://docs.gitlab.com/ce/ci/introduction/)
before_script:
  - apt-get install rubygems ruby-dev -y

run-test:
  script:
    - ruby --version

Relevant Code:

*Initially I couldn't register the gitlab-runner out of the box, hence the step 2 and 3. However after registration, the runner executes the run-test job above, and outputs the following error:

Running with gitlab-runner 11.10.1 (1f513601)
  on laradock-runner pVzsSz4s
Using Shell executor...
Running on 8843859c1642...
Initialized empty Git repository in /home/gitlab-runner/builds/pVzsSz4s/0/root/my-project/.git/
Fetching changes...
Created fresh repository.
fatal: unable to access 'http://gitlab-ci-token:[MASKED]@localhost/root/my-project.git/': Failed to connect to localhost port 80: Connection refused
ERROR: Job failed: exit status 1

I also don't understand why it's trying to connect to localhost, when .env file is configured as GITLAB_CI_SERVER_URL=http://gitlab
Here is the cat /etc/gitlab-runner/config.toml for reference:

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "laradock-runner"
  url = "http://gitlab"
  token = "HrFQkYHZf41NKECrtLxS"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

[[runners]]
  name = "laradock-runner"
  url = "http://gitlab"
  token = "DWoYSFT3qdcXxk_escbZ"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]

[[runners]]
  name = "laradock-runner"
  url = "http://gitlab"
  token = "pVzsSz4sn_6vzyVABQa7"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
@sevillaarvin
Copy link
Contributor Author

sevillaarvin commented May 13, 2019

I found the culprit, upon inspecting gitlab-runner logs, the runner receiving wrong repo_url ($ docker-compose logs gitlab-runner)

gitlab-runner_1        | Checking for jobs... received                       job=10 repo_url=http://localhost/root/my-project.git runner=pVzsSz4s
gitlab-runner_1        | WARNING: Job failed: exit status 1                  duration=152.846576ms job=10 project=2 runner=pVzsSz4s
gitlab-runner_1        | ERROR: Failed to process runner                     builds=0 error=exit status 1 executor=shell runner=pVzsSz4s

Changed .env file:

GITLAB_DOMAIN_NAME=http://gitlab

However, a new permission error appears:

Running with gitlab-runner 11.10.1 (1f513601)
  on laradock-runner pVzsSz4s
Using Shell executor...
Running on 837a5d135017...
Reinitialized existing Git repository in /home/gitlab-runner/builds/pVzsSz4s/0/root/my-project/.git/
Fetching changes...
From http://gitlab/root/capstone3
 * [new branch]      staging    -> origin/staging
 * [new branch]      test/pipeline -> origin/test/pipeline
Checking out c9aa75fb as test/pipeline...
Skipping object checkout, Git LFS is not installed.

Skipping Git submodules setup
$ apt-get install rubygems ruby-dev -y
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
ERROR: Job failed: exit status 1

@sevillaarvin
Copy link
Contributor Author

sevillaarvin commented May 13, 2019

To allow superuser permissions, my solution was to change the user from gitlab-runner to root as stated here https://gitlab.com/gitlab-org/gitlab-runner/issues/2934#note_142602259

docker-compose exec gitlab-runner bash
gitlab-runner run --user=root

Nevermind, this seems to be inaccurate, as according to the dockerfile, use is set to gitlab-runner by default. It shouldn't matter anyway, if RUN_EXECUTOR is set to docker:

        - RUNNER_EXECUTOR=docker
        - DOCKER_IMAGE=alpine
        - DOCKER_NETWORK_MODE=laradock_backend

@stale
Copy link

stale bot commented Feb 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale label Feb 2, 2020
@stale
Copy link

stale bot commented Feb 23, 2020

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant