Runners, executors and tags
How a job finds a runner, why a job waits forever, and what concurrency changes.
cd ~/lab && curl -fsSLO https://secopslog.com/lab-files/ci-gitlab/runners.tar.gz && tar -xzf runners.tar.gz, which creates ~/lab/runners/. SHA-256: a4132fa8c0df26af343b482e93df1f094babe1f61319d072a5edac43e81f583a"The pipeline is stuck" is one of the most common messages in a CI channel, and it usually isn't stuck at all. A job is pending because no runner wants it, or every runner that would take it is busy. Once you know how a job and a runner find each other, you can tell which in a couple of minutes.
What a runner is
GitLab never runs your jobs. It keeps a queue, and runners poll it. A runner is a GitLab Runner process somewhere you control: a VM, a Kubernetes pod, a laptop. Each runner has an executor that decides how a job runs: shell runs it directly on the host, docker starts a container per job, kubernetes starts a pod. This lab's runner uses the Docker executor:
concurrent = 1 means this runner process takes one job at a time. image is the default when a job names none. privileged = false keeps job containers unprivileged, and network_mode puts them on the lab network so they can reach http://gitlab:8929. runner.sh registered it the current way: it asks GitLab's API to create a runner, which returns a runner authentication token (glrt-...), and gitlab-runner register stores that token in this file. The older flow with a shared registration token is deprecated, so don't build new automation on it. Guard the glrt- token: whoever has it can pose as this runner and receive its jobs, protected ones and their secrets included. Keep config.toml readable only by the runner, and check the runner list for managers you don't recognise.
An instance runner serves every project on this GitLab. Group runners serve the projects in their group and its subgroups, and project runners serve only their own project. tag_list and run_untagged decide which jobs it accepts.
Tags pick the runner
# Which runner picks up a job is decided by tags. Two jobs in one stage can run side by side,# if the runner allows more than one job at a time.default:image: secopslog-py:3.15tags: [docker]where:stage: buildscript:- echo "runner=$CI_RUNNER_DESCRIPTION tags=$CI_RUNNER_TAGS"- echo "container=$(hostname) user=$(id -un) dir=$CI_PROJECT_DIR"slow-a:stage: testscript:- echo "a start $(date +%T)"; sleep 8; echo "a end $(date +%T)"slow-b:stage: testscript:- echo "b start $(date +%T)"; sleep 8; echo "b end $(date +%T)"gpu:stage: testtags: [gpu]rules:- if: $WANT_GPU == "yes"script:- nvidia-smi
default: tags: [docker] asks every job for a runner that has the docker tag. A runner takes a job only if it has all the tags the job asks for. A job's own tags: replaces the default instead of adding to it, so gpu asks for gpu only. With no stages: list, GitLab's default stages apply: build, test and deploy, plus .pre and .post. And gpu's rules: add it only when the pipeline variable WANT_GPU is yes, which the rules lesson explains in full. Run it:
The job container ran as root, because that's the image's default user, and the builds directory is /builds/root/app. And slow-b started only after slow-a ended, although they're in the same stage, because the runner takes one job at a time.
A job no runner will take
The gpu job asks for a gpu tag, which no runner has. run-pipeline.sh starts a pipeline through the API with WANT_GPU=yes, so its rule adds the job:
Nothing failed, and nothing will. The job sits in pending with no runner, and the pipeline stays running until someone cancels it or a runner with that tag appears. In the UI, GitLab marks such a job as stuck and says no runner matches its tags. When a pipeline seems frozen, compare the job's tags with your runners' tags before you look anywhere else.
Concurrency
Raise concurrent to 2 in the runner's config file. The runner watches the file and reloads it without a restart:
The parallel step first cancelled the pipeline with the stuck gpu job, so it no longer holds a slot, and then started a new one. Now both slow jobs started in the same second. Concurrency is capacity on the runner side. Stages and needs only decide what may run, and whether jobs really overlap depends on free slots on runners that accept them. The same applies to a machine: concurrent = 10 on a 2-CPU VM makes ten jobs share two CPUs.
Hands-on
Register a second runner that has the gpu tag: ./runner.sh gpu gpu-runner. It is the same lab container with a second [[runners]] entry, so the "GPU" is pretend. Start a pipeline with ./run-pipeline.sh app WANT_GPU=yes, wait for it with ./pipeline.sh app/, and list every gpu job with the runner that took it: ./gl.sh '/projects/root%2Fapp/jobs?per_page=20' | jq -r '.[] | select(.name=="gpu") | "\(.id) \(.status) \(.runner.description)"'. It will fail, because the image has no nvidia-smi, but it will no longer wait. Finish with ./down.sh.
What you should see: gpu-runner came online with the gpu tag, and this time the gpu job was picked up at once by gpu-runner, then failed with nvidia-smi: command not found and exit code 127. Listing the gpu jobs shows both attempts: the new one failed, runner=gpu-runner, and the one from the walkthrough canceled, runner=none, because no runner ever took it. A failure on the right runner is progress: the job no longer waits for a tag nobody has.
Remember
GitLab queues jobs and runners pull them, matched by tags. A pending job with no runner is a tag or capacity problem, not a broken pipeline. concurrent is the runner's job limit, and a stage never runs faster than the runners allow.
tags: [linux, large]. Runner A has tags linux, runner B has linux, large, arm64. Which runner can take it?large.running for an hour. One job is pending and no runner is assigned. What should you check first?