Skip to content

Fix issue #29381: Missing labels from Docker config when starting service containers

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

What does this MR do?

This MR ensures that all labels defined in the Docker config are present added when creating the container Config for service containers

Why was this MR needed?

As mentioned in this issue, custom labels added in the runners.docker.container_labels section of the Gitlab runner config.toml were not being added to containers created by the executor.

This is important for customers who need to have custom container labels added to their Gitlab job containers for monitoring purposes. For example, when container metrics are collected with cAdvisor, it is useful to have the custom labels available when exporting to and querying from Prometheus.

What's the best way to test this MR?

A unit test is included in this MR, however, to perform a functional test, the following steps can be performed:

  1. Register a runner with the following configuration:
[[runners]]
  name = "example"
  ...
  [runners.docker]
    memory = "..."
    cpus = "..."
    ...
    [runners.docker.container_labels]
      "some_custom_label" = "some_custom_value"
  1. Start a job that is tagged with this runner
  2. Run docker container inspect <container> and verify that the label ending in some_custom_label exists with the value some_custom_value

What are the relevant issue numbers?

Edited by Axel von Bertoldi

Merge request reports

Loading