GitLab runner system ID is not unique in docker runner

Summary

The System ID generated by gitlab-runner is supposed to be globally unique.

However, in practice, we've found that the generated runner ID is both (1) deterministic and (2) the same every time we register a new runner.

This is because the image includes the /etc/gitlab-runner/.runner_system_id file, which means a new one will never be generated.

Steps to reproduce

  1. Start a new container from the image gitlab/gitlab-runner:v15.8.2

Find that the contents of /etc/gitlab-runner/.runner_system_id are already present and that the value is r_y3jEhmF8fN58.

docker run --rm -it --entrypoint=""  gitlab/gitlab-runner:v15.8.2 /bin/bash -c "cat /etc/gitlab-runner/.runner_system_id"

output:

r_y3jEhmF8fN58

This behavior is also present in the latest image.

Actual behavior

The system ID is deterministic, even on different systems, in different containers.

Expected behavior

  1. The .runner_system_id file should not be present in the gitlab-runner image
  2. The generated system ID should be globally unique -- that is, it should never (or virtually never) produce the same system ID.

Relevant logs and/or screenshots

You can see the following two jobs were run on two different runners, which reside on two different physical (EC2) hosts, in different containers. However, both use the same system ID. When running the gitlab-runner image locally, I also see the same ID.

screenshots

image

image

Environment

There aren't really any environment-specific factors here, except for the fact that we do not use docker volume mounts for /etc/gitlab-runner on our runners. If a volume mount is used, it will clobber the pre-existing .runner_system_id file, avoiding this issue (assuming your mount is unique per system).

Possible fixes

Ensure the /etc/gitlab-runner/.runner_system_id is not present in published docker images.

Edited by Spencer Phillip Young