gitlab-runner register ignores proxy settings
Summary
gitlab-runner register ignores proxy settings in environmet variables.
systemctl show --property=Environment gitlab-runner displays proper proxy settings.
Steps to reproduce
- Install and setup docker-ce and ensure that
docker run hello-worldworks behind your proxy. - Install latest gitlab-runner_amd64.deb
- Add environment variables to
[Service]section in/etc/systemd/system/gitlab-runner.service
[Service]
Environment="HTTP_PROXY=http://proxy.omgtu:8080/"
Environment="HTTPS_PROXY=http://proxy.omgtu:8080/"
Environment="FTP_PROXY=http://proxy.omgtu:8080/"
Environment="http_proxy=http://proxy.omgtu:8080/"
Environment="https_proxy=http://proxy.omgtu:8080/"
Environment="ftp_proxy=http://proxy.omgtu:8080/"
- Reload config file and service and ensure that environment variables have been catched up:
sudo systemctl daemon-reload
sudo systemctl restart gitlab-runner.service
sudo systemctl show --property=Environment gitlab-runner
Output:
Environment=HTTP_PROXY=http://proxy.omgtu:8080/ HTTPS_PROXY=http://proxy.omgtu:8080/ FTP_PROXY=http://proxy.omgtu:8080/ http_proxy=http://proxy.omgtu:8080/ https_proxy=http://proxy.omgtu:8080/ ftp_proxy=http://proxy.omgtu:8080/
- Try to register new runner:
sudo gitlab-runner --debug register
Runtime platform arch=amd64 os=linux pid=1383 revision=577f813d version=12.5.0
Checking runtime mode GOOS=linux uid=0
Running in system-mode.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://gitlab.com/
Please enter the gitlab-ci token for this runner:
yoEZ4RqN5RT179TRNYCs
Please enter the gitlab-ci description for this runner:
[debian-ak]:
Please enter the gitlab-ci tags for this runner (comma separated):
pc309, pc309only
Actual behavior
Prints:
Dialing: tcp gitlab.com:443 ...
ERROR: Registering runner... failed runner=yoEZ5RqN status=couldn't execute POST against https://gitlab.com/api/v4/runners: Post https://gitlab.com/api/v4/runners: dial tcp 35.231.145.151:443: i/o timeout
PANIC: Failed to register this runner. Perhaps you are having network problems
Key problem is that it tries to connect to gitlab.com directly: Dialing: tcp gitlab.com:443 ...
Expected behavior
Dialing: tcp proxy.omgtu:8080 ...
Registering runner... succeeded
It should connect via proxy: Dialing: tcp proxy.omgtu:8080 ...
Environment description
/etc/systemd/system/gitlab-runner.service contents
[Unit]
Description=GitLab Runner
After=syslog.target network.target
ConditionFileIsExecutable=/usr/lib/gitlab-runner/gitlab-runner
[Service]
Environment="HTTP_PROXY=http://proxy.omgtu:8080/"
Environment="HTTPS_PROXY=http://proxy.omgtu:8080/"
Environment="FTP_PROXY=http://proxy.omgtu:8080/"
Environment="http_proxy=http://proxy.omgtu:8080/"
Environment="https_proxy=http://proxy.omgtu:8080/"
Environment="ftp_proxy=http://proxy.omgtu:8080/"
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/lib/gitlab-runner/gitlab-runner "run" "--working-directory" "/home/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--syslog" "--user" "gitlab-runner"
Restart=always
RestartSec=120
[Install]
WantedBy=multi-user.target
Used GitLab Runner version
Version: 12.5.0 Git revision: 577f813d Git branch: 12-5-stable GO version: go1.10.8 Built: 2019-11-20T09:14:54+0000 OS/Arch: linux/amd64