我在设置 GitLab 上玩得很开心,在花了很长时间修改它之后,我已经相对习惯了设置它,现在已经在两台机器上完成了,第二次比本来……
但是,我在两台机器上都面临着一个相当大的问题:我的 CI 管道坏了。不知何故,我的设置在构建完成后向工件提供 403,这意味着技术上成功的每一项工作都注定要失败......
我一直在互联网上寻找答案,但我没有找到太多有用的东西。
我在几分钟前将 GitLab CE 升级到 10.1.4,并将 GitLab-runner 升级到 10.1.0,我可以通过 apt 在两台机器中更重要的机器上使用最新的软件包,运行比另一台更新版本的 Ubuntu - “野兽”的 17.04 zesty 与“q2”的 16.10 yakkety 相比。 gitlab-runner 注册都使用 shell 来执行。
CI作业的相关输出如下:
Cloning repository...
Cloning into '/[clonepath]'...
Checking out 8319d586 as master...
Skipping Git submodules setup
mesg: ttyname failed: Inappropriate ioctl for device
mesg: ttyname failed: Inappropriate ioctl for device
mesg: ttyname failed: Inappropriate ioctl for device
$ mvn -B install
[INFO] Scanning for projects...
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.204 s
[INFO] Finished at: 2017-11-18T05:45:08+01:00
[INFO] Final Memory: 27M/640M
[INFO] ------------------------------------------------------------------------
mesg: ttyname failed: Inappropriate ioctl for device
mesg: ttyname failed: Inappropriate ioctl for device
mesg: ttyname failed: Inappropriate ioctl for device
Uploading artifacts...
target/*.jar: found 1 matching files
ERROR: Uploading artifacts to coordinator... forbidden id=35 responseStatus=403
Forbidden status=403 Forbidden token=sP9oHykF
FATAL: permission denied
ERROR: Job failed: exit status 1
我在 Apache2 Vhost 子域下运行 GitLab,主要是为了美观和省略主机后面的端口,即 8080 代表独角兽,因为还有其他站点在 Apache 上运行。
这些是我的 gitlab.rb 中配置的选项:
gitlab_rails['trusted_proxies'] = [ '127.0.0.1' ]
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8181"
nginx['enable'] = false
在以下任一选项/值中设置值
web_server['username'] = 'www-data'
web_server['group'] = 'www-data'
在重新配置时产生错误:
Starting Chef Client, version 12.12.15
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
- package (0.1.0)
- registry (0.1.0)
- consul (0.0.0)
- gitlab (0.0.1)
- runit (0.14.2)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe: gitlab::default
* directory[/etc/gitlab] action create (up to date)
Converging 408 resources
* directory[/etc/gitlab] action create (up to date)
* directory[Create /var/opt/gitlab] action create (up to date)
* directory[/opt/gitlab/embedded/etc] action create (up to date)
* template[/opt/gitlab/embedded/etc/gitconfig] action create (up to date)
Recipe: gitlab::web-server
* group[Webserver user and group] action create (up to date)
* user[Webserver user and group] action create
================================================================================
Error executing action `create` on resource 'user[Webserver user and group]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '8'
---- Begin output of ["usermod", "-s", "/bin/false", "-d", "/var/opt/gitlab/nginx", "www-data"] ----
STDOUT:
STDERR: usermod: user www-data is currently used by process 2656
---- End output of ["usermod", "-s", "/bin/false", "-d", "/var/opt/gitlab/nginx", "www-data"] ----
Ran ["usermod", "-s", "/bin/false", "-d", "/var/opt/gitlab/nginx", "www-data"] returned 8
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/definitions/account.rb
38: user params[:name] do
39: username username
40: shell params[:shell]
41: home params[:home]
42: uid params[:uid]
43: gid params[:ugid]
44: system params[:system]
45: supports params[:user_supports]
46: action params[:action]
47: end
48: end
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/package/definitions/account.rb:38 :in `block in from_file'
user("Webserver user and group") do
params {:action=>nil, :username=>"www-data", :uid=>nil, :ugid=>"www-data", :groupname=>"www-data", :gid=>nil, :shell=>"/bin/false", :home=>"/var/opt/gitlab/nginx", :system=>true, :append_to_group=>true, :group_members=>["www-data"], :user_supports=>{:manage_home=>false}, :manage=>true, :name=>"Webserver user and group"}
action [:create]
supports {:manage_home=>false}
retries 0
retry_delay 2
default_guard_interpreter :default
username "www-data"
gid 33
home "/var/opt/gitlab/nginx"
shell "/bin/false"
system true
iterations 27855
declared_type :user
cookbook_name "gitlab"
recipe_name "web-server"
end
Platform:
---------
x86_64-linux
Running handlers:
Running handlers complete
Chef Client failed. 0 resources updated in 04 seconds
对于 Apache,这是支持 SSL 的虚拟主机:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName [host]
ServerAdmin [email]
DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
ServerSignature Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Location />
Order deny,allow
Allow from all
Require all granted
ProxyPassReverse http://127.0.0.1:8181/
ProxyPassReverse http://[host]/
RequestHeader set X-Forwarded-Ssl 'on'
</Location>
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/uploads/.*
RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]
SSLCertificateFile /etc/letsencrypt/live/[host]/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/[host]/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
知道发生了什么事吗?我还没有挖掘 Apache 日志信息,因为它可能不会是 Apache,因为请求直接进入 gitlab-worker (8181)。如有必要,我应该检查哪些日志?
谢谢你的时间。
这不是一个特别有用的答案,因为该解决方案对其工作原理几乎没有解释。
我的配置和上面一样,但是我安装的运行器,我删除了配置,
rm /etc/gitlab-runner/config.toml
,然后继续从机器中删除包,apt purge gitlab-runner
。 (gitlab-ci-multi-runner 是另一个可用的包,但似乎不是最新的 GitLab 10 - 返回 404 而不是连接到节点)。
我重新安装了runner,
apt install gitlab-runner
,然后注册了它-gitlab-runner register
。这里要注意的关键是,在注册期间,我使用了我的 FQDN,如 https://git.example.com 而不是任何本地地址,例如 http://localhost:8080 或 http:/ /localhost:8181(分别为 unicorn、gitlab-workhorse)。是的,我在我的本地机器上运行我的跑步者。危险,但我太信任我的团队了。这可能是我们的失败,无知的系统管理是成功的关键。
在我的例子中,我不得不将代理 URL 中的“https://”替换为“http://”。 虽然我的错误是不同的,但认为它可能是相关的。
WARNING: Retrying... context=artifacts-uploader error=invalid argument
ERROR: Uploading artifacts as "archive" to coordinator... error error=couldn't execute POST against https://<mycompanygitlabserver.com>/api/v4/jobs/4370107/artifacts?artifact_format=zip&artifact_type=archive: Post "<mycompanygitlabserver.com>/api/v4/jobs/4370107/artifacts?artifact_format=zip&artifact_type=archive": proxyconnect tcp: read tcp xx.xx.123.xxx:55664->xx.xxx.132.xxx:83: wsarecv: An existing connection was forcibly closed by the remote host. id=4370107 token=64_aGdss
FATAL: invalid argument
感谢作者给出的答案暗示我重新查看我的注册命令