Terry : Upgrade GitLab From 5.4 To 6.0

GitLab 6.0

Major Improvements

  • First and foremost are the improved groups
    From now on a group is not just a directory for projects. It also allows you to add users. After user is added to group – it automatically get access to all existing and new projects inside group. You can also have have multiple owners for a group who can manage members/projects. With this GitLab becomes more group oriented. That is why we no longer support global namespaces. Project can be part of group or user only.
  • Merge requests are now possible between a fork and the original project
    Another nice improvement comes from contributor Izaak Alpert. It allows you to use different workflow depending on your needs.
  • Now you can create or remove both git branches and tags with the GitLab UI
    It gives you ability to work with the web ui only. For example to create branch, fix something with the web editor and submit a Merge Request.
  • Also we polished our UI and made a lot of bug fixes
    Under the hood we refactored a lot of stuff and improved the performance. And one last piece of good news. The upgrade to 6.0 is not so complicated as it used to be for major versions. The only big change is that all projects must be part of a group or user. A bit of preparations, few commands – and you are running GitLab 6.
  • Unicorn is default web server again
    Switched from Puma back to Unicorn again. As Puma causes 100% CPU and memory leak when running multi-thread mode where concurrency is high (because of MRI, should be using JRuby or Rubynius according to this => commit).

Upgrade Steps

0. backup

Backup saves lives.

NOTE: With MySQL, this may require granting "LOCK TABLES" privileges to the GitLab user on the database version.

cd /home/git/gitlab
sudo -u git -H RAILS_ENV=production bundle exec rake gitlab:backup:create

1. Stop the server

sudo service gitlab stop

2. Get the latest code for GitLab

# GitLab
su - git
cd /home/git/gitlab
git fetch
git checkout 6-0-stable

3. Update GitLab Shell

# GitLab shell
cd /home/git/gitlab-shell
git pull
git checkout v1.7.0

NOTE: DO NOT forget to check config.yml to make sure the FQDN is correct. 

4. Install Additional Packages

# For reStructuredText markup language support install required package
sudo apt-get install python-docutils

5. Install libs, migrations, etc.

cd /home/git/gitlab

sudo -u git -H bundle install --without development test postgres --deployment

sudo -u git -H bundle install --without development test mysql --deployment

sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
sudo -u git -H bundle exec rake migrate_groups RAILS_ENV=production
sudo -u git -H bundle exec rake migrate_global_projects RAILS_ENV=production
sudo -u git -H bundle exec rake migrate_keys RAILS_ENV=production
sudo -u git -H bundle exec rake migrate_inline_notes RAILS_ENV=production

sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

6. Update config files

Note: In GitLab 6, the default web server switched to Unicorn from Puma.

7. Update init script

# Backup the old init scriptsudo cp /etc/init.d/gitlab{,.old}sudo rm /etc/init.d/gitlab
# Download the new init script
sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/6-0-stable/lib/support/init.d/gitlab
# OR
cd /etc/init.d && sudo wget --no-check-certificate -O gitlab https://raw.github.com/gitlabhq/gitlabhq/6-0-stable/lib/support/init.d/gitlab
sudo chmod +x /etc/init.d/gitlab

8. Update Nginx Configuration File

# backup old config filecp /etc/nginx/sites-available/gitlab{,.5-4}
rm -f /etc/nginx/sites-available/gitlab
# download the latest config file
sudo wget --no-check-certificate -O /etc/nginx/sites-available https://raw.github.com/gitlabhq/gitlabhq/master/lib/support/nginx/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

IMPORTANT: add nginx user to the git group to give it access to assets under /home/git/gitlab/public. For Ubuntu Server, for this instance Ubuntu Server uses www-data instead of nginx. Otherwise assets (PNG,  CSS files cannot be loaded due to permission denied error).

# add nginx user to git group:
sudo usermod -a -G git nginx
sudo chmod g+rx /home/git/

# or replace the default nginx user with git and group root in /etc/nginx/nginx.conf:
#user             nginx;
user              git root;

Refer to GitLab Recipes.

9. Start GitLab

sudo service gitlab start

10. Check Application Status

Check if GitLab and its environment are configured correctly

su git
cd /home/git/gitlab && bundle exec rake gitlab:env:info RAILS_ENV=production

To make sure you didn't miss anything run a more thorough check with

su git
cd /home/git/gitlab && bundle exec rake gitlab:check RAILS_ENV=production

If all items are green, then congratulations upgrade complete!