Skip to content

[SOLUTION FOUND] GitLab runner helper does not respect /etc/hosts

Solution

gitlab/gitlab-runner-helper image is missing /etc/nsswitch.conf see my comment for more details.

Summary

/usr/bin/gitlab-runner-helper does not respect /etc/hosts

Steps to reproduce

Actually just try to upload artifacts... when runner has extra_hosts = ["my-domain.net:10.0.0.2"] and my-domain.net is not reachable via real IP address resolved via DNS.

I simulated it also via:

docker run -it --rm --add-host=my-domain.net:10.0.0.2 cache-image-hash /usr/bin/gitlab-runner-helper artifacts-uploader --token {VALID TOKEN taken from logs} --url https://my-domain.net/ --id {SOME ID}

Actual behavior

This is spat out:

ERROR: Uploading artifacts to coordinator... error  error=couldn't execute POST against https://my-domain.net/api/v4/jobs/{SOME ID}/artifacts?: Post https://my-domain.net/api/v4/jobs/67/artifacts?: dial tcp {REAL IP OF DOMAIN RESOLVED VIA DNS}:443: getsockopt: connection refused id={SOME ID} token={TOKEN}

Expected behavior

No error. Well I expect /usr/bin/gitlab-runner-helper artifacts-uploader to resolve IP address using /etc/hosts just like when cloning the git repository.

Environment description

Custom installation, latest.

Used GitLab Runner version

Runner in question is using docker.

martinkiesel@server:~$ docker run --rm cache-image-hash /usr/bin/gitlab-runner-helper --version
Version:      10.2.0
Git revision: 0a75cdd1
Git branch:   10-2-stable
GO version:   go1.8.3
Built:        Wed, 22 Nov 2017 09:08:57 +0000
OS/Arch:      linux/amd64
Edited by Martin Kiesel