Gitlab API无法访问

时间:2017-09-20 13:46:55

标签: docker gitlab

我在docker容器中运行gitlab 9.5.5,当我通过http在新存储库中进行第一次推送时,我收到以下错误:

* upload completely sent off: 387 out of 387 bytes
< HTTP/1.1 200 OK
< Server: nginx
< Date: Wed, 20 Sep 2017 13:17:43 GMT
< Content-Type: application/x-git-receive-pack-result
< Content-Length: 118
< Connection: keep-alive
< Cache-Control: no-cache
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
<
* Connection #1 to host localhost left intact
remote: GitLab: API is not accessible
To http://localhost/root/project01.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://localhost/root/project01.git'

容器:

IMAGE                    PORTS                     NAMES
images/gitlab-nginx      0.0.0.0:80->80/tcp        test_nginx_1
images/gitlab:9.5        test_sidekiq_1
images/gitlab:9.5        0.0.0.0:22->22/tcp        test_sshd_1
images/gitlab:9.5        8181/tcp                  test_workhorse_1
images/gitlab:9.5        8080/tcp                  test_gitlab_1
images/gitlab:9.5        9999/tcp                  test_gitaly_1
images/postgres:9.6      5432/tcp                  test_postgres_1
images/redis             6379/tcp                  test_redis_1

容器日志:

gitaly_1     | {"args":["/usr/bin/git","receive-pack","--stateless-rpc","--advertise-refs","/mnt/data/repositories/root/project01.git"],"grpc.method":"InfoRefsReceivePack","grpc.request.repoPath":"root/project01.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"root","grpc.service":"gitaly.SmartHTTP","level":"info","msg":"spawn","path":"/usr/bin/git","peer.address":{"IP":"172.18.0.6","Port":34318,"Zone":""},"span.kind":"server","system":"grpc","time":"2017-09-20T13:22:54Z"}
gitaly_1     | {"args":["/usr/bin/git","receive-pack","--stateless-rpc","--advertise-refs","/mnt/data/repositories/root/project01.git"],"command.exitCode":0,"command.inblock":0,"command.maxrss":5872,"command.oublock":0,"command.real_time_ms":3.1934519999999997,"command.system_time_ms":0,"command.user_time_ms":0,"grpc.method":"InfoRefsReceivePack","grpc.request.repoPath":"root/project01.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"root","grpc.service":"gitaly.SmartHTTP","level":"info","msg":"spawn complete","path":"/usr/bin/git","peer.address":{"IP":"172.18.0.6","Port":34318,"Zone":""},"span.kind":"server","system":"grpc","time":"2017-09-20T13:22:54Z"}
gitaly_1     | {"grpc.code":"OK","grpc.method":"InfoRefsReceivePack","grpc.request.repoPath":"root/project01.git","grpc.request.repoStorage":"default","grpc.request.topLevelGroup":"root","grpc.service":"gitaly.SmartHTTP","grpc.time_ms":3,"level":"info","msg":"finished streaming call","peer.address":{"IP":"172.18.0.6","Port":34318,"Zone":""},"span.kind":"server","system":"grpc","time":"2017-09-20T13:22:54Z"}
workhorse_1  | localhost 172.18.0.9:43596 - - "GET /root/project01.git/info/refs?service=git-receive-pack HTTP/1.1" 200 180 "" "git/2.11.0 (Apple Git-81)" 0.152725
nginx_1      | 172.18.0.1 - root "GET /root/project01.git/info/refs?service=git-receive-pack HTTP/1.1" 200 180 "-" "git/2.11.0 (Apple Git-81)"
gitlab_1     | INFO -- : Started POST "/root/project01.git/git-receive-pack" for 172.18.0.6 at 2017-09-20 13:22:54 +0000
gitlab_1     | INFO -- : Processing by Projects::GitHttpController#git_receive_pack as application/x-git-receive-pack-result
gitlab_1     | INFO -- :   Parameters: {"namespace_id"=>"root", "project_id"=>"project01.git"}
gitlab_1     | INFO -- : Completed 200 OK in 170ms (Views: 1.4ms | ActiveRecord: 11.3ms)
gitlab_1     | INFO -- : Started POST "/api/v4/internal/allowed" for 172.18.0.6 at 2017-09-20 13:22:55 +0000
workhorse_1  | localhost 172.18.0.9:43606 - - [2017-09-20 13:22:54.793530983 +0000 UTC] "POST /root/project01.git/git-receive-pack HTTP/1.1" 200 113 "" "git/2.11.0 (Apple Git-81)" 0.502495
nginx_1      | 172.18.0.1 - root [20/Sep/2017:13:22:55 +0000] "POST /root/project01.git/git-receive-pack HTTP/1.1" 200 113 "-" "git/2.11.0 (Apple Git-81)"

我通过production.rb启用了gitlab调试日志,但没有任何用处,只有db请求。主分支不受保护。

我发现一些信息表明这可能是由于网址不匹配而导致的,我使用以下内容:

在gitlab-shell.yml

gitlab_url: "http://gitlab:8080"

在gitlab.yml中:

production: &base
  gitlab:
    host: localhost

我试图改变最后一个ti gitlab或0.0.0.0,没有帮助。

看起来这个错误来自gitlab-shell,但我的日志中没有看到任何内容。

1 个答案:

答案 0 :(得分:0)

根据current gitlab architecture scheme,我没有预料到的主力容器触发gitlab shell。在将gitlab shell secret添加到workhorse容器之后,我已经解决了这个问题。