docker executor: use DNS, DNSSearch and ExtraHosts settings from configuration
What does this MR do?
This MR changes service container instantiation to set DNS
, DNSSearch
and ExtraHosts
configuration, as already done for the regular containers.
Why was this MR needed?
Due to various reasons, for example when gitlab and it's registry are reachable internally and externally from different IP adresses, users might want to set custom DNS servers, DNS search domains and extra hosts in their gitlab runner configuration.
This setting wasn't applied to services specified in the .gitlab-ci.yml, for example leading to connection failures/timeouts when using docker:dind
to build and push images to GitLab's registry.
Are there points in the code the reviewer needs to double check?
Does this MR meet the acceptance criteria?
-
Documentation created/updated (prepared branch for gitlab-ce project) -
Added tests for this feature/bug -
In case of conflicts with master
- branch was rebased - no conflicts
What are the relevant issue numbers?
Merge request reports
Activity
mentioned in issue #2959 (closed)
Current test coverage seems to be pretty sparse, not sure about the best way to add it.
As far as documentation goes, I think it makes more sense to add docs to https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/ci/docker/using_docker_images.md#what-is-a-service
I prepared a branch for that at https://gitlab.com/flokli/gitlab-ce/tree/gitlab-runner-services-dns-hosts
cc @ayufan
We do mostly black box tests to verify the workflows.
So, if you can do some workflow with service that test that behavior it would be preferred.
Generally, this fix seems OK. The question is how we ensure that it will not break over time :)
@ayufan I grabbed the runner artifact from the pipeline, replaced our runner binaries with that one, and retriggered the job, which then behaved properly. So I can confirm it works :-)
I could write a textual document explaining the process, sure - but adding some example project to do the testing isn't really possible, as it also requires reconfiguring the runner (setting addn-hosts or dns related options in the runner configuration)…
Edited by Florian Klinkadded 1 commit
- 1aac30a2 - executor_docker_test: add tests for DNS, DNSSearch and ExtraHosts
added 1 commit
- 0e833372 - executor_docker_test: add tests for DNS, DNSSearch and ExtraHosts
added 1 commit
- 62c0822f - executor_docker_test: add tests for DNS, DNSSearch and ExtraHosts
@ayufan I added three tests, one for each setting to
executor_docker_test.go
. Ascce
is run for both the regular container and the service container, we assure that both are set to the one specified in the executors config.Let me know if there's anything more needed :-)
added Community contribution executordocker + 1 deleted label
changed milestone to %11.6
mentioned in commit 6c7b8fd2
is this documented somewhere? How to use eg.
ExtraHosts
for my docker containers with gitlab-runner? I would like to set the hosts ideally for all containers or atleast for a single container.Basically my question is where to set this extrahost so
e.Config.Docker.ExtraHosts
will get it.Edited by Melroy van den Berg