Skip to content

artifact upload does not use extra_hosts

Summary

The artifact upload functionality after a build is run does not appear to use any IPs defined within extra_hosts.

I was able to find a few similar issues, but they'd all been closed when the issue reporter found workarounds, but the core issue of extra_hosts not being used to resolve IPs during artifact upload still exists.

Related: #1323 (closed), gitlab-org/gitlab-ce#14212, #1037 (closed)

Steps to reproduce

  1. Add an entry to gitlab-runner.toml for GitLab host (e.g. extra_hosts = ["gitlab.local:127.0.0.1"])
  2. Run a build with an artifact defined.

Actual behavior

Build fails when artifacts cannot be uploaded to coordinator due to attempting to connect to an invalid IP

Expected behavior

Build should succeed with artifacts uploaded.

Relevant logs and/or screenshots

gitlab-runner.toml:

concurrent = 2

[[runners]]
  name = "docker-runner"
  url = "https://gitlab.local/ci"
  tls-skip-verify = true
  token = "[TOKEN]"
  environment = ["COMPOSER_CACHE_DIR=/cache/composer"]
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "busybox"
    privileged = false
    disable_cache = false
    volumes = ["/cache"]
    extra_hosts = ["gitlab.local:127.0.0.1"]
  [runners.cache]
    Insecure = false

Build Log Excerpt:

ERROR: Uploading artifacts to coordinator... error  error=couldn't execute POST against https://gitlab.local/ci/api/v1/builds/5086/artifacts?: Post https://gitlab.local/ci/api/v1/builds/5086/artifacts?: dial tcp [IP that isn't 127.0.0.1]:443: i/o timeout id=5086 token=[TOKEN]
FATAL: invalid argument                            
ERROR: Build failed: exit code 1

Environment description

Using docker to run both gitlab and the runner, using extra_hosts to tell runner the IP of the GitLab machine (which has worked for everything involving runner activity except artifacts).

docker-compose.yml:

version: '2'
services:
  gitlab:
    image: gitlab/gitlab-ce:8.13.2-ce.0
    ports:
    - "2222:22"
    expose:
    - "80"
    volumes:
    - ~/data/gitlab/config:/etc/gitlab
    - ~/data/gitlab/logs:/var/log/gitlab
    - ~/data/gitlab/data:/var/opt/gitlab
    networks:
      default:
        aliases:
        - gitlab.local

  gitlab-runner:
    image: gitlab/gitlab-runner
    volumes:
    - ./gitlab-runner.toml:/etc/gitlab-runner/config.toml
    - /var/run/docker.sock:/var/run/docker.sock

Used GitLab Runner version

Version:      1.7.1
Git revision: f896af7
Git branch:   1-7-stable
GO version:   go1.7.3
Built:        Tue, 25 Oct 2016 16:57:56 +0000
OS/Arch:      linux/amd64