Skip to content

Commit c5132e9

Browse files
committed
Switch to gitlab-workhorse
1 parent 3c23b65 commit c5132e9

File tree

8 files changed

+249
-65
lines changed

8 files changed

+249
-65
lines changed

GITLAB_GIT_HTTP_SERVER_VERSION

-1
This file was deleted.

GITLAB_WORKHORSE_VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.3.1

doc/update/8.1-to-8.2.md

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# From 8.1 to 8.2
2+
3+
**NOTE:** GitLab 8.0 introduced several significant changes related to
4+
installation and configuration which *are not duplicated here*. Be sure you're
5+
already running a working version of 8.0 before proceeding with this guide.
6+
7+
### 0. Double-check your Git version
8+
9+
**This notice applies only to /usr/local/bin/git**
10+
11+
If you compiled Git from source on your GitLab server then please double-check
12+
that you are using a version that protects against CVE-2014-9390. For six
13+
months after this vulnerability became known the GitLab installation guide
14+
still contained instructions that would install the outdated, 'vulnerable' Git
15+
version 2.1.2.
16+
17+
Run the following command to get your current Git version:
18+
19+
```sh
20+
/usr/local/bin/git --version
21+
```
22+
23+
If you see 'No such file or directory' then you did not install Git according
24+
to the outdated instructions from the GitLab installation guide and you can go
25+
to the next step 'Stop server' below.
26+
27+
If you see a version string then it should be v1.8.5.6, v1.9.5, v2.0.5, v2.1.4,
28+
v2.2.1 or newer. You can use the [instructions in the GitLab source
29+
installation
30+
guide](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md#1-packages-dependencies)
31+
to install a newer version of Git.
32+
33+
### 1. Stop server
34+
35+
sudo service gitlab stop
36+
37+
### 2. Backup
38+
39+
```bash
40+
cd /home/git/gitlab
41+
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
42+
```
43+
44+
### 3. Get latest code
45+
46+
```bash
47+
sudo -u git -H git fetch --all
48+
sudo -u git -H git checkout -- db/schema.rb # local changes will be restored automatically
49+
```
50+
51+
For GitLab Community Edition:
52+
53+
```bash
54+
sudo -u git -H git checkout 8-2-stable
55+
```
56+
57+
OR
58+
59+
For GitLab Enterprise Edition:
60+
61+
```bash
62+
sudo -u git -H git checkout 8-2-stable-ee
63+
```
64+
65+
### 4. Update gitlab-shell
66+
67+
```bash
68+
cd /home/git/gitlab-shell
69+
sudo -u git -H git fetch
70+
sudo -u git -H git checkout v2.6.5
71+
```
72+
73+
### 5. Replace gitlab-git-http-server with gitlab-workhorse
74+
75+
Install and compile gitlab-workhorse. This requires [Go
76+
1.5](https://golang.org/dl) which should already be on your system
77+
from GitLab 8.1.
78+
79+
```bash
80+
cd /home/git
81+
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git
82+
sudo -u git -H git checkout 0.3.1
83+
sudo -u git -H make
84+
```
85+
86+
Update the GitLab init script and 'default' file.
87+
88+
```
89+
cd /home/git/gitlab
90+
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
91+
test -e /etc/default/gitlab && \
92+
sudo sed -i .pre-8.2 's/^\([^=]*\)gitlab_git_http_server/\1gitlab_workhorse/' /etc/default/gitlab
93+
```
94+
95+
Make sure that you also update your **NGINX configuration** to use
96+
the new gitlab-workhorse.socket file.
97+
98+
### 6. Install libs, migrations, etc.
99+
100+
```bash
101+
cd /home/git/gitlab
102+
103+
# MySQL installations (note: the line below states '--without postgres')
104+
sudo -u git -H bundle install --without postgres development test --deployment
105+
106+
# PostgreSQL installations (note: the line below states '--without mysql')
107+
sudo -u git -H bundle install --without mysql development test --deployment
108+
109+
# Run database migrations
110+
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
111+
112+
# Clean up assets and cache
113+
sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
114+
115+
# Update init.d script
116+
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
117+
```
118+
119+
### 7. Update configuration files
120+
121+
#### New configuration options for `gitlab.yml`
122+
123+
There are new configuration options available for [`gitlab.yml`](config/gitlab.yml.example). View them with the command below and apply them manually to your current `gitlab.yml`:
124+
125+
```sh
126+
git diff origin/8-1-stable:config/gitlab.yml.example origin/8-2-stable:config/gitlab.yml.example
127+
```
128+
129+
#### Nginx configuration
130+
131+
View changes between the previous recommended Nginx configuration and the
132+
current one:
133+
134+
```sh
135+
# For HTTPS configurations
136+
git diff origin/8-1-stable:lib/support/nginx/gitlab-ssl origin/8-2-stable:lib/support/nginx/gitlab-ssl
137+
138+
# For HTTP configurations
139+
git diff origin/8-1-stable:lib/support/nginx/gitlab origin/8-2-stable:lib/support/nginx/gitlab
140+
```
141+
142+
If you are using Apache instead of NGINX please see the updated [Apache templates].
143+
Also note that because Apache does not support upstreams behind Unix sockets you
144+
will need to let gitlab-git-http-server listen on a TCP port. You can do this
145+
via [/etc/default/gitlab].
146+
147+
[Apache templates]: https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/web-server/apache
148+
[/etc/default/gitlab]: https://gitlab.com/gitlab-org/gitlab-ce/blob/8-2-stable/lib/support/init.d/gitlab.default.example#L34
149+
150+
### 8. Start application
151+
152+
sudo service gitlab start
153+
sudo service nginx restart
154+
155+
### 9. Check application status
156+
157+
Check if GitLab and its environment are configured correctly:
158+
159+
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
160+
161+
To make sure you didn't miss anything run a more thorough check:
162+
163+
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
164+
165+
If all items are green, then congratulations, the upgrade is complete!
166+
167+
## Things went south? Revert to previous version (8.0)
168+
169+
### 1. Revert the code to the previous version
170+
171+
Follow the [upgrade guide from 7.14 to 8.0](7.14-to-8.0.md), except for the database migration
172+
(The backup is already migrated to the previous version)
173+
174+
### 2. Restore from the backup
175+
176+
```bash
177+
cd /home/git/gitlab
178+
sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
179+
```
180+
181+
If you have more than one backup `*.tar` file(s) please add `BACKUP=timestamp_of_backup` to the command above.
182+
183+
## Troubleshooting
184+
185+
### "You appear to have cloned an empty repository."
186+
187+
See the [7.14 to 8.0 update guide](7.14-to-8.0.md#troubleshooting).

lib/gitlab/backend/grack_auth.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def call(env)
3434
auth!
3535

3636
if project && authorized_request?
37-
# Tell gitlab-git-http-server the request is OK, and what the GL_ID is
37+
# Tell gitlab-workhorse the request is OK, and what the GL_ID is
3838
render_grack_auth_ok
3939
elsif @user.nil? && !@ci
4040
unauthorized

lib/support/init.d/gitlab

+33-35
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ web_server_pid_path="$pid_path/unicorn.pid"
3737
sidekiq_pid_path="$pid_path/sidekiq.pid"
3838
mail_room_enabled=false
3939
mail_room_pid_path="$pid_path/mail_room.pid"
40-
gitlab_git_http_server_pid_path="$pid_path/gitlab-git-http-server.pid"
41-
gitlab_git_http_server_options="-listenUmask 0 -listenNetwork unix -listenAddr $socket_path/gitlab-git-http-server.socket -authBackend http://127.0.0.1:8080"
42-
gitlab_git_http_server_repo_root='/home/git/repositories'
43-
gitlab_git_http_server_log="$app_root/log/gitlab-git-http-server.log"
40+
gitlab_workhorse_pid_path="$pid_path/gitlab-workhorse.pid"
41+
gitlab_workhorse_options="-listenUmask 0 -listenNetwork unix -listenAddr $socket_path/gitlab-workhorse.socket -authBackend http://127.0.0.1:8080"
42+
gitlab_workhorse_log="$app_root/log/gitlab-workhorse.log"
4443
shell_path="/bin/bash"
4544

4645
# Read configuration variable file if it is present
@@ -76,8 +75,8 @@ check_pids(){
7675
else
7776
spid=0
7877
fi
79-
if [ -f "$gitlab_git_http_server_pid_path" ]; then
80-
hpid=$(cat "$gitlab_git_http_server_pid_path")
78+
if [ -f "$gitlab_workhorse_pid_path" ]; then
79+
hpid=$(cat "$gitlab_workhorse_pid_path")
8180
else
8281
hpid=0
8382
fi
@@ -94,7 +93,7 @@ check_pids(){
9493
wait_for_pids(){
9594
# We are sleeping a bit here mostly because sidekiq is slow at writing it's pid
9695
i=0;
97-
while [ ! -f $web_server_pid_path ] || [ ! -f $sidekiq_pid_path ] || [ ! -f $gitlab_git_http_server_pid_path ] || { [ "$mail_room_enabled" = true ] && [ ! -f $mail_room_pid_path ]; }; do
96+
while [ ! -f $web_server_pid_path ] || [ ! -f $sidekiq_pid_path ] || [ ! -f $gitlab_workhorse_pid_path ] || { [ "$mail_room_enabled" = true ] && [ ! -f $mail_room_pid_path ]; }; do
9897
sleep 0.1;
9998
i=$((i+1))
10099
if [ $((i%10)) = 0 ]; then
@@ -131,9 +130,9 @@ check_status(){
131130
fi
132131
if [ $hpid -ne 0 ]; then
133132
kill -0 "$hpid" 2>/dev/null
134-
gitlab_git_http_server_status="$?"
133+
gitlab_workhorse_status="$?"
135134
else
136-
gitlab_git_http_server_status="-1"
135+
gitlab_workhorse_status="-1"
137136
fi
138137
if [ "$mail_room_enabled" = true ]; then
139138
if [ $mpid -ne 0 ]; then
@@ -143,7 +142,7 @@ check_status(){
143142
mail_room_status="-1"
144143
fi
145144
fi
146-
if [ $web_status = 0 ] && [ $sidekiq_status = 0 ] && [ $gitlab_git_http_server_status = 0 ] && { [ "$mail_room_enabled" != true ] || [ $mail_room_status = 0 ]; }; then
145+
if [ $web_status = 0 ] && [ $sidekiq_status = 0 ] && [ $gitlab_workhorse_status = 0 ] && { [ "$mail_room_enabled" != true ] || [ $mail_room_status = 0 ]; }; then
147146
gitlab_status=0
148147
else
149148
# http://refspecs.linuxbase.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
@@ -171,9 +170,9 @@ check_stale_pids(){
171170
exit 1
172171
fi
173172
fi
174-
if [ "$hpid" != "0" ] && [ "$gitlab_git_http_server_status" != "0" ]; then
175-
echo "Removing stale gitlab-git-http-server pid. This is most likely caused by gitlab-git-http-server crashing the last time it ran."
176-
if ! rm "$gitlab_git_http_server_pid_path"; then
173+
if [ "$hpid" != "0" ] && [ "$gitlab_workhorse_status" != "0" ]; then
174+
echo "Removing stale gitlab-workhorse pid. This is most likely caused by gitlab-workhorse crashing the last time it ran."
175+
if ! rm "$gitlab_workhorse_pid_path"; then
177176
echo "Unable to remove stale pid, exiting"
178177
exit 1
179178
fi
@@ -190,7 +189,7 @@ check_stale_pids(){
190189
## If no parts of the service is running, bail out.
191190
exit_if_not_running(){
192191
check_stale_pids
193-
if [ "$web_status" != "0" ] && [ "$sidekiq_status" != "0" ] && [ "$gitlab_git_http_server_status" != "0" ] && { [ "$mail_room_enabled" != true ] || [ "$mail_room_status" != "0" ]; }; then
192+
if [ "$web_status" != "0" ] && [ "$sidekiq_status" != "0" ] && [ "$gitlab_workhorse_status" != "0" ] && { [ "$mail_room_enabled" != true ] || [ "$mail_room_status" != "0" ]; }; then
194193
echo "GitLab is not running."
195194
exit
196195
fi
@@ -206,8 +205,8 @@ start_gitlab() {
206205
if [ "$sidekiq_status" != "0" ]; then
207206
echo "Starting GitLab Sidekiq"
208207
fi
209-
if [ "$gitlab_git_http_server_status" != "0" ]; then
210-
echo "Starting gitlab-git-http-server"
208+
if [ "$gitlab_workhorse_status" != "0" ]; then
209+
echo "Starting gitlab-workhorse"
211210
fi
212211
if [ "$mail_room_enabled" = true ] && [ "$mail_room_status" != "0" ]; then
213212
echo "Starting GitLab MailRoom"
@@ -230,15 +229,14 @@ start_gitlab() {
230229
RAILS_ENV=$RAILS_ENV bin/background_jobs start &
231230
fi
232231

233-
if [ "$gitlab_git_http_server_status" = "0" ]; then
234-
echo "The gitlab-git-http-server is already running with pid $spid, not restarting"
232+
if [ "$gitlab_workhorse_status" = "0" ]; then
233+
echo "The gitlab-workhorse is already running with pid $spid, not restarting"
235234
else
236-
# No need to remove a socket, gitlab-git-http-server does this itself
237-
$app_root/bin/daemon_with_pidfile $gitlab_git_http_server_pid_path \
238-
$app_root/../gitlab-git-http-server/gitlab-git-http-server \
239-
$gitlab_git_http_server_options \
240-
$gitlab_git_http_server_repo_root \
241-
>> $gitlab_git_http_server_log 2>&1 &
235+
# No need to remove a socket, gitlab-workhorse does this itself
236+
$app_root/bin/daemon_with_pidfile $gitlab_workhorse_pid_path \
237+
$app_root/../gitlab-workhorse/gitlab-workhorse \
238+
$gitlab_workhorse_options \
239+
>> $gitlab_workhorse_log 2>&1 &
242240
fi
243241

244242
if [ "$mail_room_enabled" = true ]; then
@@ -268,21 +266,21 @@ stop_gitlab() {
268266
echo "Shutting down GitLab Sidekiq"
269267
RAILS_ENV=$RAILS_ENV bin/background_jobs stop
270268
fi
271-
if [ "$gitlab_git_http_server_status" = "0" ]; then
272-
echo "Shutting down gitlab-git-http-server"
273-
kill -- $(cat $gitlab_git_http_server_pid_path)
269+
if [ "$gitlab_workhorse_status" = "0" ]; then
270+
echo "Shutting down gitlab-workhorse"
271+
kill -- $(cat $gitlab_workhorse_pid_path)
274272
fi
275273
if [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; then
276274
echo "Shutting down GitLab MailRoom"
277275
RAILS_ENV=$RAILS_ENV bin/mail_room stop
278276
fi
279277

280278
# If something needs to be stopped, lets wait for it to stop. Never use SIGKILL in a script.
281-
while [ "$web_status" = "0" ] || [ "$sidekiq_status" = "0" ] || [ "$gitlab_git_http_server_status" = "0" ] || { [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; }; do
279+
while [ "$web_status" = "0" ] || [ "$sidekiq_status" = "0" ] || [ "$gitlab_workhorse_status" = "0" ] || { [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; }; do
282280
sleep 1
283281
check_status
284282
printf "."
285-
if [ "$web_status" != "0" ] && [ "$sidekiq_status" != "0" ] && [ "$gitlab_git_http_server_status" != "0" ] && { [ "$mail_room_enabled" != true ] || [ "$mail_room_status" != "0" ]; }; then
283+
if [ "$web_status" != "0" ] && [ "$sidekiq_status" != "0" ] && [ "$gitlab_workhorse_status" != "0" ] && { [ "$mail_room_enabled" != true ] || [ "$mail_room_status" != "0" ]; }; then
286284
printf "\n"
287285
break
288286
fi
@@ -292,7 +290,7 @@ stop_gitlab() {
292290
# Cleaning up unused pids
293291
rm "$web_server_pid_path" 2>/dev/null
294292
# rm "$sidekiq_pid_path" 2>/dev/null # Sidekiq seems to be cleaning up it's own pid.
295-
rm -f "$gitlab_git_http_server_pid_path"
293+
rm -f "$gitlab_workhorse_pid_path"
296294
if [ "$mail_room_enabled" = true ]; then
297295
rm "$mail_room_pid_path" 2>/dev/null
298296
fi
@@ -303,7 +301,7 @@ stop_gitlab() {
303301
## Prints the status of GitLab and it's components.
304302
print_status() {
305303
check_status
306-
if [ "$web_status" != "0" ] && [ "$sidekiq_status" != "0" ] && [ "$gitlab_git_http_server_status" != "0" ] && { [ "$mail_room_enabled" != true ] || [ "$mail_room_status" != "0" ]; }; then
304+
if [ "$web_status" != "0" ] && [ "$sidekiq_status" != "0" ] && [ "$gitlab_workhorse_status" != "0" ] && { [ "$mail_room_enabled" != true ] || [ "$mail_room_status" != "0" ]; }; then
307305
echo "GitLab is not running."
308306
return
309307
fi
@@ -317,10 +315,10 @@ print_status() {
317315
else
318316
printf "The GitLab Sidekiq job dispatcher is \033[31mnot running\033[0m.\n"
319317
fi
320-
if [ "$gitlab_git_http_server_status" = "0" ]; then
321-
echo "The gitlab-git-http-server with pid $hpid is running."
318+
if [ "$gitlab_workhorse_status" = "0" ]; then
319+
echo "The gitlab-workhorse with pid $hpid is running."
322320
else
323-
printf "The gitlab-git-http-server is \033[31mnot running\033[0m.\n"
321+
printf "The gitlab-workhorse is \033[31mnot running\033[0m.\n"
324322
fi
325323
if [ "$mail_room_enabled" = true ]; then
326324
if [ "$mail_room_status" = "0" ]; then
@@ -360,7 +358,7 @@ reload_gitlab(){
360358
## Restarts Sidekiq and Unicorn.
361359
restart_gitlab(){
362360
check_status
363-
if [ "$web_status" = "0" ] || [ "$sidekiq_status" = "0" ] || [ "$gitlab_git_http_server" = "0" ] || { [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; }; then
361+
if [ "$web_status" = "0" ] || [ "$sidekiq_status" = "0" ] || [ "$gitlab_workhorse" = "0" ] || { [ "$mail_room_enabled" = true ] && [ "$mail_room_status" = "0" ]; }; then
364362
stop_gitlab
365363
fi
366364
start_gitlab

0 commit comments

Comments
 (0)