Running gitlab-runner as a specific user - /etc/systemd/systemd/gitlab-runner.service.d ignored

Summary

An existing issue (3675) has a comment that states creating /etc/systemd/system/gitlab-runner.service.d/exec_start.conf will allow any future updates to gitlab-runner to use that systemd config. However, with the file in place, an error is thrown:

FATAL: Please specify user that will run gitlab-runner service

Steps to reproduce

Create /etc/systemd/system/gitlab-runner.service.d/exec_start.conf with content similar to this:

[Service]
ExecStart=
ExecStart=/usr/bin/gitlab-runner "run" "--config" "/etc/gitlab-runner/config.toml" "--working-directory" "/home/user1" "--service" "gitlab-runner" "--user" "user1"

Execute

gitlab-runner uninstall
gitlab-runner install

Actual behavior

# gitlab-runner uninstall
Runtime platform                                    arch=amd64 os=linux pid=17218 revision=66269445 version=17.3.1

# gitlab-runner install
Runtime platform                                    arch=amd64 os=linux pid=17306 revision=66269445 version=17.3.1
FATAL: Please specify user that will run gitlab-runner service

Expected behavior

The gitlab-runner service would have its systemd config ExecStart line be set to the following and gitlab-runner processes would reflect the same:

ExecStart=/usr/bin/gitlab-runner "run" "--config" "/etc/gitlab-runner/config.toml" "--working-directory" "/home/user1" "--service" "gitlab-runner" "--user" "user1"

Relevant logs and/or screenshots

# for file in /etc/systemd/system/gitlab-runner.service.d/*; do echo -e "\n--------\n$file\n--------\n"; cat $file; done

--------
/etc/systemd/system/gitlab-runner.service.d/exec_start.conf
--------

[Service]
ExecStart=
ExecStart=/usr/bin/gitlab-runner "run" "--config" "/etc/gitlab-runner/config.toml" "--working-directory" "/home/user1" "--service" "gitlab-runner" "--user" "user1"


# gitlab-runner uninstall
Runtime platform                                    arch=amd64 os=linux pid=17218 revision=66269445 version=17.3.1

# gitlab-runner install
Runtime platform                                    arch=amd64 os=linux pid=17306 revision=66269445 version=17.3.1
FATAL: Please specify user that will run gitlab-runner service

# gitlab-runner install --user user1 --working-directory /home/user1
Runtime platform                                    arch=amd64 os=linux pid=17320 revision=66269445 version=17.3.1

Environment description

These are our on-prem runners on Ubuntu 22.04

$ dpkg -l gitlab-runner
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  gitlab-runner  17.3.1-1     amd64        GitLab Runner
config.toml contents
concurrent = 1
check_interval = 0
connection_max_age = "15m0s"
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "hostname"
  url = "https://gitlab.com"
  id = someid
  token = ""
  token_obtained_at = 2024-08-21T19:15:04Z
  token_expires_at = 0001-01-01T00:00:00Z
  executor = "shell"
  [runners.custom_build_dir]
  [runners.cache]
    MaxUploadedArchiveSize = 0
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]

Used GitLab Runner version

Version:      17.3.1
Git revision: 66269445
Git branch:   17-3-stable
GO version:   go1.22.5
Built:        2024-08-21T15:24:26+0000
OS/Arch:      linux/amd64
Edited by Tom Fox