Home > Blockchain >  gitlab runner with 2 workers: 1st worker (BE) fine, 2nd worker (FE) uses docker instead of shell
gitlab runner with 2 workers: 1st worker (BE) fine, 2nd worker (FE) uses docker instead of shell

Time:10-18

Firstly I set up 1 worker for 1 job. Deploying my backend for the API.

I'm using "shell" as the executer. The .toml file is this structure:

concurrent = 1
check_interval = 0

[session_server]
   session_timeout = 1800

[[runners]]
  name = "Gitlab Runner Josere Backend"
  url = "https://gitlab.com/"
  token = "sOmEtOkeN1G0Tfr0mGitlab"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [some mumbo jumbo about caching.. does it matter?]

With some struggle I got that to work fine with this .gitlab-ci.yml:

deploy-production:
  stage: deploy
  variables:
    GIT_STRATEGY: clone
  script:
    - cd ./lumen/
    - composer install
    - sudo cp -r $CI_PROJECT_DIR/lumen/. /home/josere/public_html/api/
    - sudo cp /home/josere/env/.env /home/josere/public_html/api

This is the execution output of the runner:

Running with gitlab-runner 15.2.1 (32fc1585)
  on Gitlab Runner Josere backend 9JxGrMLz
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on ####[my server]#####...
Getting source from Git repository
00:03
Fetching changes with git depth set to 50...
Initialized empty Git repository in /home/gitlab-runner/builds/9JxGrMLz/0/paspalas/josere/.git/
Created fresh repository.
... etc ...

In my frontend repo in Gitlab I went to the same runners settings. I can't really install a runner (its allready running I guess) but I can copy the token that is shown there.

Then I changed my .toml file according to this doc from gitlab (https://docs.gitlab.com/runner/fleet_scaling/):

concurrent = 2
check_interval = 0

[session_server]
   session_timeout = 1800

[[runners]]
  name = "Gitlab Runner Josere Backend"
  url = "https://gitlab.com/"
  token = "sOmEtOkeN1G0Tfr0mGitlab"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [some mumbo jumbo about caching.. does it matter?]

[[runners]]
  name = "Gitlab Runner Josere Frontend"
  url = "https://gitlab.com/"
  token = "TheOtherTokenThatIgotFromFrontendRepo!"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    [some mumbo jumbo about caching.. does it matter?]

notice I do keep the executor on "shell". this is the script for .gitlab-ci.yml that goes in the root of the frontend repo:

deploy-production:
  stage: deploy
  variables:
    GIT_STRATEGY: clone
  script:
    - npm install
    - npm run build
    - sudo cp -r $CI_PROJECT_DIR/public/. /home/josere/public_html/

But when I commit my frontend and check the (failing) log for the worker it writes this:

Running with gitlab-runner 15.4.0~beta.5.gdefc7017 (defc7017)
  on green-1.shared.runners-manager.gitlab.com/default JLgUopmM
Preparing the "docker machine" executor
00:06
Using Docker executor with image ruby:2.5 ...
Pulling docker image ruby:2.5 ...
Using docker image sha256:27d###mumbojumbo###2383b for ruby:2.5 with digest ruby@sha256:ecc3###mumbojumbo###444b ...
Preparing environment
00:00
Running on runner-jlguopmm-project-39467125-concurrent-0 via runner-jlguopmm-shared-1665674167-6adf45bf...
Getting source from Git repository
00:02
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/paspalas/josere-frontend/.git/
Created fresh repository.
Checking out c39e641c as materialui...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
Using docker image sha256:27d###mumbojumbo###3b for ruby:2.5 with digest ruby@sha256:ecc3e###mumbojumbo####44b ...
$ sudo npm install
/bin/bash: line 126: sudo: command not found
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

clearly it seems multiple things go wrong, to start with: why is it using docker while I explicitly tell it to be "shell"?

CodePudding user response:

I fixed the issue. Even though the docs of GitLab differentiates between "runner" and "job", the gitlab-runner calls these "registrations" of a "runner". I did the (extra) registeration like so:

- gitlab-runner register
[filling in info]
- nano /etc/gitlab-runner/config.toml
[check if you have the additional runner]
- gitlab-runner run
[according to gitlab-runner help this is to fire up multiple runners]
- gitlab-runner list
[ now you can check if all "runners" (jobs) are running]
  • Related