Repository Import from URL fails if Gitlab is hosted behind a proxy
We have a hosted Gitlab installation and we need to pass through a proxy to access external sites. Import from URL fails when trying to import an external repo with: "Failed to connect to github.com port 443: Connection timed out"
Errors:
2018-09-14_14:25:07.83994 time="2018-09-14T14:25:07Z" level=info msg="fatal: unable to access 'https://github.com/kanatohodets/ci-test.git/': Failed to connect to github.com port 443: Connection timed out" grpc.meta.client_name=gitlab-sidekiq grpc.method=CreateRepositoryFromURL grpc.request.glRepository= grpc.request.repoPath=savramoiu/ci-test-2.git grpc.request.repoStorage=default grpc.request.topLevelGroup=savramoiu grpc.service=gitaly.RepositoryService peer.address=@ span.kind=server system=grpc
2018-09-14_14:25:07.89566 time="2018-09-14T14:25:07Z" level=error msg="finished unary call" error="rpc error: code = Internal desc = CreateRepositoryFromURL: clone cmd wait: exit status 128" grpc.code=Internal grpc.meta.client_name=gitlab-sidekiq grpc.method=CreateRepositoryFromURL grpc.request.glRepository= grpc.request.repoPath=savramoiu/ci-test-2.git grpc.request.repoStorage=default grpc.request.topLevelGroup=savramoiu grpc.service=gitaly.RepositoryService grpc.time_ms=213900 peer.address=@ span.kind=server system=grpc
We added proxy env variables for gitaly in gitlab.rb:
gitaly['env'] = {"http_proxy"=>"http://webproxy:3128", "https_proxy"=>"http://webproxy:3128", "no_proxy"=>"127.0.0.1,localhost,internal.com"}
And we see it in env variables for the gitaly process, but they are not present in the environment for the git process spawned to clone the external repo:
$ ps -ef | grep kanat
git 38254 28745 0 16:23 ? 00:00:00 /opt/gitlab/embedded/bin/git clone --bare -- https://github.com/kanatohodets/ci-test.git /var/opt/gitlab/git-data/repositories/savramoiu/ci-test-1.git
git 38266 38254 0 16:23 ? 00:00:00 /opt/gitlab/embedded/libexec/git-core/git-remote-https origin https://github.com/kanatohodets/ci-test.git
$ sudo cat /proc/38254/environ
GIT_TERMINAL_PROMPT=0HOME=/var/opt/gitlabPATH=/opt/gitlab/bin:/opt/gitlab/embedded/bin:/bin:/usr/binTZ=:/etc/localtime
$ sudo cat /proc/38266/environ
GIT_DIR=/var/opt/gitlab/git-data/repositories/savramoiu/ci-test-1.gitGIT_TERMINAL_PROMPT=0HOME=/var/opt/gitlabPATH=/opt/gitlab/embedded/libexec/git-core:/opt/gitlab/bin:/opt/gitlab/embedded/bin:/bin:/usr/binTZ=:/etc/localtime
#gitaly process:
$ sudo cat /proc/28745/environ
OLDPWD=/opt/gitlab/sv/gitalyHOME=/var/opt/gitlabPWD=/var/opt/gitlab/gitalySHLVL=0PATH=/opt/gitlab/bin:/opt/gitlab/embedded/bin:/bin:/usr/binTZ=:/etc/localtimePYTHONPATH=/opt/gitlab/embedded/lib/python3.4/site-packagesICU_DATA=/opt/gitlab/embedded/share/icu/currenthttp_proxy=http://webproxy:3128https_proxy=http://webproxy:3128no_proxy=127.0.0.1,localhost,internal.comGID=930UID=930