Skip to content

Runner defaults are not honoured when registering runner with a configuration template

Summary

Registering a runner with a configuration template results in configuration that does not respect the documented runner defaults.

Steps to reproduce

  1. Create a minimal configuration template:

    > cat config-template.toml
    concurrent = 50
    log_format = "text"
    
    [[runners]]
      executor = "docker-autoscaler"
      tls-ca-file = "/etc/gitlab-runner/certs/ca.pem"
      limit = 0
      output_limit = 102400
    
      [runners.docker]
        image = "ubuntu:24.04"
        privileged = true
        wait_for_services_timeout = 600 # seconds
    
      [runners.autoscaler]
        plugin = "fleeting-plugin-aws"
        capacity_per_instance = 1
        max_use_count = 5
    
        [runners.autoscaler.connector_config]
          username = "ec2-user"
    
        [[runners.autoscaler.policy]]
          idle_count = 0
          idle_time = "5m"
  2. Using the GitLab runner image, output the default runner configuration, then register the configuration template:

    > docker run --rm -it --entrypoint bash --volume ./config-template.toml:/etc/gitlab-runner/config-template.toml docker.io/gitlab/gitlab-runner:latest
    root@d2007f74d17c:/# cat /etc/gitlab-runner/config.toml
    concurrent = 1
    check_interval = 0
    shutdown_timeout = 0
    
    [session_server]
      session_timeout = 1800
    root@d2007f74d17c:/# CI_SERVER_URL=https://gitlab.com /entrypoint register --non-interactive --template-config /etc/gitlab-runner/config-template.toml --token <redacted>
    Runtime platform                                    arch=arm64 os=linux pid=17 revision=b92ee590 version=17.4.0
    Running in system-mode.
    
    Merging configuration from template file "/etc/gitlab-runner/config-template.toml"
    Verifying runner... is valid                        runner=t2_wFmqRp
    Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
    
    Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml"
  3. Output the runner configuration with the merged configuration template:

    root@d2007f74d17c:/# cat /etc/gitlab-runner/config.toml
    concurrent = 1
    check_interval = 0
    connection_max_age = "15m0s"
    shutdown_timeout = 0
    
    [session_server]
      session_timeout = 1800
    
    [[runners]]
      name = "d2007f74d17c"
      output_limit = 102400
      url = "https://gitlab.com"
      id = 41736210
      token = "<redacted>"
      token_obtained_at = 2024-10-07T20:20:17Z
      token_expires_at = 0001-01-01T00:00:00Z
      tls-ca-file = "/etc/gitlab-runner/certs/ca.pem"
      executor = "docker-autoscaler"
      [runners.custom_build_dir]
      [runners.cache]
        MaxUploadedArchiveSize = 0
        [runners.cache.s3]
        [runners.cache.gcs]
        [runners.cache.azure]
      [runners.docker]
        tls_verify = false
        image = "ubuntu:24.04"
        privileged = true
        disable_entrypoint_overwrite = false
        oom_kill_disable = false
        disable_cache = false
        volumes = ["/cache"]
        wait_for_services_timeout = 600
        shm_size = 0
        network_mtu = 0
      [runners.autoscaler]
        capacity_per_instance = 1
        max_use_count = 5
        max_instances = 0
        plugin = "fleeting-plugin-aws"
        update_interval = "0s"
        update_interval_when_expecting = "0s"
        [runners.autoscaler.connector_config]
          username = "ec2-user"
          password = ""
          key_path = ""
          use_static_credentials = false
          keepalive = "0s"
          timeout = "0s"
          use_external_addr = false
    
        [[runners.autoscaler.policy]]
          idle_count = 0
          idle_time = "5m0s"
          scale_factor = 0.0
          scale_factor_limit = 0

Actual behavior

The following [runners.autoscaler] properties are set:

[runners.autoscaler]
  ...
  update_interval = "0s"
  update_interval_when_expecting = "0s"
  [runners.autoscaler.connector_config]
    ...
    keepalive = "0s"
    timeout = "0s"
    ...

Expected behavior

Either the update_interval and update_interval_when_expecting properties should either be omitted, or set to the documented defaults of 1m and 2s respectively.

No defaults are documented for the keepalive and timeout values, so it's unclear if they are incorrect, but if they deviate from the defaults they should either be omitted or set to the default runner values.

Environment description

config-template.toml contents
concurrent = 50
log_format = "text"

[[runners]]
  executor = "docker-autoscaler"
  tls-ca-file = "/etc/gitlab-runner/certs/ca.pem"
  limit = 0
  output_limit = 102400

  [runners.docker]
    image = "ubuntu:24.04"
    privileged = true
    wait_for_services_timeout = 600 # seconds

  [runners.autoscaler]
    plugin = "fleeting-plugin-aws"
    capacity_per_instance = 1
    max_use_count = 5

    [runners.autoscaler.connector_config]
      username = "ec2-user"

    [[runners.autoscaler.policy]]
      idle_count = 0
      idle_time = "5m"

Used GitLab Runner version

root@d2007f74d17c:/# gitlab-runner --version
Version:      17.4.0
Git revision: b92ee590
Git branch:   17-4-stable
GO version:   go1.22.5
Built:        2024-09-19T11:11:17+0000
OS/Arch:      linux/arm64