Two runners on different hosts for one project

Hello,

I am trying to have 2 runners on different machines set up for the same project for our production environment. Both runners are successfully registered but it looks like only one of them will pick up the job. There is no pattern which of the 2 runners will pick up, its random… So I assume the first runner to see the job will pick it up while the other will ignore it.

Both runners share the same tag ‘production’ and are limited to the branch ‘production’ with the ‘only’ keyword in the .gitlab-ci.yml file:

deploy-production:
  stage: deploy
  script:
  - some magic
  tags:
  - production
  only:
  - production

Is there a way to have both runners pick up the same job?

Thanks in advance,
Ruben

No one is replying so maybe I am approaching this wrong? My goal is to deploy the same build to both production machines that share the load behind a load balancer. Is there another/preferred way to achieve this?

I have almost the same “problem”…

I have two runners registered on two servers with different environments (e.g. different compilers).
I would like the same job to be “sent” to both runners as can be done easily with buildbot for example…

possible ? have you a solution for your problem ?

best,

Hi,

we ended up copying the config and setting it up it for the runners per instance. So something like:

.deployscript: [your script here]

deploy-production1:
  stage: deploy
  script:
  - *deployscript
  tags:
  - production1
  only:
  - production


deploy-production2:
  stage: deploy
  script:
  - *deployscript
  tags:
  - production2
  only:
  - production

Jobs are only run once by one runner. That’s just how jobs work.

if you need something done on multiple machines, you have two choices:

  • Make one job that does all that needs to be done
  • Make multiple job, and if the job needs to be executed on different machines use a corresponding number of tags to make them picked up by those machnes.