diff options
-rw-r--r-- | app/assets/stylesheets/common.scss | 21 | ||||
-rw-r--r-- | app/assets/stylesheets/gitlab_bootstrap/blocks.scss | 2 | ||||
-rw-r--r-- | app/assets/stylesheets/gitlab_bootstrap/common.scss | 21 | ||||
-rw-r--r-- | app/models/user.rb | 6 | ||||
-rw-r--r-- | app/views/admin/background_jobs/show.html.haml | 34 | ||||
-rw-r--r-- | app/views/admin/users/show.html.haml | 39 | ||||
-rw-r--r-- | app/views/projects/issues/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/merge_requests/show/_mr_box.html.haml | 7 | ||||
-rw-r--r-- | app/views/projects/milestones/show.html.haml | 4 | ||||
-rw-r--r-- | doc/install/installation.md | 5 | ||||
-rw-r--r-- | doc/make_release.md | 21 | ||||
-rw-r--r-- | doc/update/5.4-to-6.0.md | 18 | ||||
-rw-r--r-- | lib/api/helpers.rb | 8 | ||||
-rwxr-xr-x | lib/support/init.d/gitlab | 13 | ||||
-rw-r--r-- | lib/support/logrotate/gitlab | 22 | ||||
-rw-r--r-- | lib/tasks/gitlab/check.rake | 2 | ||||
-rw-r--r-- | lib/tasks/sidekiq.rake | 27 | ||||
-rwxr-xr-x | script/background_jobs | 56 | ||||
-rwxr-xr-x | script/web | 49 |
19 files changed, 273 insertions, 84 deletions
diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index a3156ec10fc..dc36d6f7923 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -140,27 +140,6 @@ p.time { border-bottom: 2px solid #F90; } -.status_info { - font-size: 14px; - padding: 5px 15px; - line-height: 26px; - text-align: center; - float: right; - position: relative; - top: -5px; - @include border-radius(4px); - - &.success { - background: #4A4; - color: #FFF; - } - - &.error { - background: #DA4E49; - color: #FFF; - } -} - .thin_area{ height: 150px; } diff --git a/app/assets/stylesheets/gitlab_bootstrap/blocks.scss b/app/assets/stylesheets/gitlab_bootstrap/blocks.scss index f0a77bb8add..1493367317f 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/blocks.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/blocks.scss @@ -34,6 +34,8 @@ &.ui-box-show { margin:20px 0; background: #FFF; + box-shadow: inset 0 1px 0 #fff, 0 1px 5px #f1f1f1; + @include linear-gradient(#fafafa, #f1f1f1); .control-group { margin-bottom: 0; diff --git a/app/assets/stylesheets/gitlab_bootstrap/common.scss b/app/assets/stylesheets/gitlab_bootstrap/common.scss index bc6c786da50..e7780b9c510 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/common.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/common.scss @@ -87,3 +87,24 @@ pre.well-pre { font-weight: bold; @include box-shadow(inset 0 2px 4px rgba(0,0,0,.15)); } + +/** Big Labels **/ +.state-label { + font-size: 14px; + padding: 5px 15px; + text-align: center; + float: right; + position: relative; + top: -5px; + @include border-radius(4px); + + &.state-label-green { + background: #4A4; + color: #FFF; + } + + &.state-label-red { + background: #DA4E49; + color: #FFF; + } +} diff --git a/app/models/user.rb b/app/models/user.rb index 22292de40a6..df14cf34e85 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -199,11 +199,7 @@ class User < ActiveRecord::Base end def by_username_or_id(name_or_id) - if (name_or_id.is_a?(Integer)) - User.find_by_id(name_or_id) - else - User.find_by_username(name_or_id) - end + where('username = ? OR id = ?', name_or_id, name_or_id).first end def build_user(attrs = {}, options= {}) diff --git a/app/views/admin/background_jobs/show.html.haml b/app/views/admin/background_jobs/show.html.haml index 2d4ffc10d5f..122e952d87a 100644 --- a/app/views/admin/background_jobs/show.html.haml +++ b/app/views/admin/background_jobs/show.html.haml @@ -2,3 +2,37 @@ %br .ui-box %iframe{src: sidekiq_path, width: '100%', height: 900, style: "border: none"} +%h4 Sidekiq running processes +- sidekiq_processes = `ps -eo euser,pid,pcpu,pmem,stat,start,command | grep sidekiq | grep -v grep` +- if sidekiq_processes.empty? + %b There are no running sidekiq processes + %b Please restart GitLab +- else + .ui-box + %table.zebra-striped + %thead + %th USER + %th + %th PID + %th + %th CPU + %th + %th MEM + %th + %th STATE + %th + %th START + %th + %th COMMAND + %th + - sidekiq_processes.split("\n").each do |process| + - next unless process.match(/(sidekiq \d+\.\d+\.\d+.+$)/) + - data = process.gsub!(/\s+/m, '|').strip.split('|') + %tr + - 6.times do + %td= data.shift + %td + %td= data.join(" ") + %b If '[25 of 25 busy]' is shown, restart GitLab with 'sudo service gitlab reload'. + %br + %b If more than one sidekiq process is listed, stop GitLab, kill the remaining sidekiq processes (sudo pkill -u git -f sidekiq) and restart GitLab. diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index df9fc687478..655ed5f7f79 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -1,5 +1,5 @@ %h3.page-title - User: + %span.cgray User: = @user.name - if @user.blocked? %span.cred (Blocked) @@ -10,8 +10,6 @@ = link_to edit_admin_user_path(@user), class: "btn grouped" do %i.icon-edit Edit - - if @user.blocked? - = link_to 'Unblock', unblock_admin_user_path(@user), method: :put, class: "btn grouped success" %hr .row @@ -67,17 +65,30 @@ = link_to @user.created_by.name, [:admin, @user.created_by] - unless @user == current_user - .alert - %h4 Block user - %br - %p Blocking user has the following effects: - %ul - %li User will not be able to login - %li User will not be able to access git repositories - %li User will be removed from joined projects and groups - %li Personal projects will be left - %li Owned groups will be left - = link_to 'Block user', block_admin_user_path(@user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-remove" + - if @user.blocked? + .alert.alert-info + %h4 This user is blocked + %br + %p Blocking user has the following effects: + %ul + %li User will not be able to login + %li User will not be able to access git repositories + %li User will be removed from joined projects and groups + %li Personal projects will be left + %li Owned groups will be left + = link_to 'Unblock user', unblock_admin_user_path(@user), method: :put, class: "btn btn-new", confirm: 'Are you sure?' + - else + .alert + %h4 Block this user + %br + %p Blocking user has the following effects: + %ul + %li User will not be able to login + %li User will not be able to access git repositories + %li User will be removed from joined projects and groups + %li Personal projects will be left + %li Owned groups will be left + = link_to 'Block user', block_admin_user_path(@user), confirm: 'USER WILL BE BLOCKED! Are you sure?', method: :put, class: "btn btn-remove" .alert.alert-error %h4 diff --git a/app/views/projects/issues/show.html.haml b/app/views/projects/issues/show.html.haml index 6d1a088721c..d08a8af2bb9 100644 --- a/app/views/projects/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -32,7 +32,7 @@ .ui-box-head %h4.box-title - if @issue.closed? - .error.status_info Closed + .state-label.state-label-red Closed = gfm escape_once(@issue.title) .ui-box-body diff --git a/app/views/projects/merge_requests/show/_mr_box.html.haml b/app/views/projects/merge_requests/show/_mr_box.html.haml index 1f750e22c65..93ae602a696 100644 --- a/app/views/projects/merge_requests/show/_mr_box.html.haml +++ b/app/views/projects/merge_requests/show/_mr_box.html.haml @@ -3,11 +3,12 @@ %h4.box-title = gfm escape_once(@merge_request.title) - if @merge_request.merged? - .success.status_info + .state-label.state-label-green %i.icon-ok Merged - elsif @merge_request.closed? - .error.status_info Closed + .state-label.state-label-red + Closed .ui-box-body %div @@ -32,7 +33,7 @@ %span %i.icon-remove Closed by #{link_to_member(@project, @merge_request.closed_event.author)} - %small #{time_ago_in_words(@merge_request.closed_event.created_at)} ago. + %span #{time_ago_in_words(@merge_request.closed_event.created_at)} ago. - if @merge_request.merged? .ui-box-bottom.alert-success %span diff --git a/app/views/projects/milestones/show.html.haml b/app/views/projects/milestones/show.html.haml index dc7fd40d5e3..2e115026ed3 100644 --- a/app/views/projects/milestones/show.html.haml +++ b/app/views/projects/milestones/show.html.haml @@ -26,9 +26,9 @@ .ui-box-head %h4.box-title - if @milestone.closed? - .error.status_info Closed + .state-label.state-label-red Closed - elsif @milestone.expired? - .error.status_info Expired + .state-label.state-label-red Expired = gfm escape_once(@milestone.title) diff --git a/doc/install/installation.md b/doc/install/installation.md index 3a3b02849f1..c3325061d6b 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -52,7 +52,7 @@ If you are not familiar with vim please skip this and keep using the default edi Install the required packages: - sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev + sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate Make sure you have the right version of Python installed. @@ -265,6 +265,9 @@ Make GitLab start on boot: sudo update-rc.d gitlab defaults 21 +## Set up logrotate + + sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab ## Check Application Status diff --git a/doc/make_release.md b/doc/make_release.md index 5be0d5980a1..7f19a17da6d 100644 --- a/doc/make_release.md +++ b/doc/make_release.md @@ -1,5 +1,6 @@ # Things to do when creating new release -NOTE: This is a developer guide. If you are trying to install GitLab see the latest stable [installation guide](install/installation.md) and if you are trying to upgrade, see the [upgrade guides](update). +NOTE: This is a guide for GitLab developers. If you are trying to install GitLab see the latest stable [installation guide](install/installation.md) and if you are trying to upgrade, see the [upgrade guides](update). + ## Install guide up to date? * References correct GitLab branch `x-x-stable` and correct GitLab shell tag? @@ -41,7 +42,7 @@ Check if changed since last release (~22nd of last month depending on when last #### 10. Check application status -## Make sure code status is good +## Make sure the code quality indicatiors are good * [](http://ci.gitlab.org/projects/1?ref=master) on ci.gitlab.org (master branch) @@ -53,4 +54,18 @@ Check if changed since last release (~22nd of last month depending on when last * [](https://coveralls.io/r/gitlabhq/gitlabhq) -## Make release branch +## Make a release branch + +After making the release branch new commits are cherry-picked from master. When the release gets closer we get more selective what is cherry-picked. + +- 5 days before release: feature freeze +- 3 days before release: UI freeze +- 1 day before release: code freeze + +## Last actions + +1. Write a blog post (mention what GitLab is on the first line, select a MVP) +1. Update VERSION and CHANGELOG +1. Create a git tag vX.X.X +1. Publish the blog post +1. Tweet about the release diff --git a/doc/update/5.4-to-6.0.md b/doc/update/5.4-to-6.0.md index 0027d91d60a..31379d81aba 100644 --- a/doc/update/5.4-to-6.0.md +++ b/doc/update/5.4-to-6.0.md @@ -111,3 +111,21 @@ To make sure you didn't miss anything run a more thorough check with: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production If all items are green, then congratulations upgrade complete! + +### Troubleshooting +The migrations in this update are very sensitive to incomplete or inconsistent data. If you have a long-running GitLab installation and some of the previous upgrades did not work out 100% correct this may bite you now. The following commands can be run in the rails console to look for 'bad' data. + +All project owners should have an owner +``` +Project.all.select { |project| project.owner.blank? } +``` + +Every user should have a namespace +``` +User.all.select { |u| u.namespace.blank? } +``` + +Projects in the global namespace should not conflict with projects in the owner namespace +``` +Project.where(namespace_id: nil).select { |p| Project.where(path: p.path, namespace_id: p.owner.try(:namespace).try(:id)).present? } +``` diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index e09a4660668..edc662eaaab 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -11,12 +11,8 @@ module API # If the sudo is the current user do nothing if (identifier && !(@current_user.id == identifier || @current_user.username == identifier)) render_api_error!('403 Forbidden: Must be admin to use sudo', 403) unless @current_user.is_admin? - begin - @current_user = User.by_username_or_id(identifier) - rescue => ex - not_found!("No user id or username for: #{identifier}") - end - not_found!("No user id or username for: #{identifier}") if current_user.nil? + @current_user = User.by_username_or_id(identifier) + not_found!("No user id or username for: #{identifier}") if @current_user.nil? end @current_user end diff --git a/lib/support/init.d/gitlab b/lib/support/init.d/gitlab index f157d71b14f..26ca50c22fa 100755 --- a/lib/support/init.d/gitlab +++ b/lib/support/init.d/gitlab @@ -22,7 +22,6 @@ RAILS_ENV="production" # /bin/sh variables such as PATH, EDITOR or SHELL. app_root="/home/git/gitlab" app_user="git" -unicorn_conf="$app_root/config/unicorn.rb" pid_path="$app_root/tmp/pids" socket_path="$app_root/tmp/sockets" web_server_pid_path="$pid_path/unicorn.pid" @@ -129,7 +128,7 @@ start() { # Remove old socket if it exists rm -f "$socket_path"/gitlab.socket 2>/dev/null # Start the webserver - bundle exec unicorn_rails -D -c "$unicorn_conf" -E "$RAILS_ENV" + RAILS_ENV=$RAILS_ENV script/web start fi # If sidekiq is already running, don't start it again. @@ -137,7 +136,7 @@ start() { echo "The Sidekiq job dispatcher is already running with pid $spid, not restarting" else echo "Starting the GitLab Sidekiq event dispatcher..." - RAILS_ENV=$RAILS_ENV bundle exec rake sidekiq:start + RAILS_ENV=$RAILS_ENV script/background_jobs start # We are sleeping a bit here because sidekiq is slow at writing it's pid sleep 2 fi @@ -151,7 +150,7 @@ stop() { exit_if_not_running # If the Unicorn web server is running, tell it to stop; if [ "$web_status" = "0" ]; then - kill -QUIT "$wpid" + RAILS_ENV=$RAILS_ENV script/web stop echo "Stopping the GitLab Unicorn web server..." stopping=true else @@ -160,7 +159,7 @@ stop() { # And do the same thing for the Sidekiq. if [ "$sidekiq_status" = "0" ]; then printf "Stopping Sidekiq job dispatcher." - RAILS_ENV=$RAILS_ENV bundle exec rake sidekiq:stop + RAILS_ENV=$RAILS_ENV script/background_jobs stop stopping=true else echo "The Sidekiq was not running, must have run out of breath." @@ -215,10 +214,10 @@ reload(){ exit 1 fi printf "Reloading GitLab Unicorn configuration... " - kill -USR2 "$wpid" + RAILS_ENV=$RAILS_ENV script/web reload echo "Done." echo "Restarting GitLab Sidekiq since it isn't capable of reloading its config..." - RAILS_ENV=$RAILS_ENV bundle exec rake sidekiq:restart + RAILS_ENV=$RAILS_ENV script/background_jobs restart # Waiting 2 seconds for sidekiq to write it. sleep 2 status diff --git a/lib/support/logrotate/gitlab b/lib/support/logrotate/gitlab new file mode 100644 index 00000000000..df9398d0795 --- /dev/null +++ b/lib/support/logrotate/gitlab @@ -0,0 +1,22 @@ +# GitLab logrotate settings +# based on: http://stackoverflow.com/a/4883967 + +/home/git/gitlab/log/*.log { + weekly + missingok + rotate 52 + compress + delaycompress + notifempty + copytruncate +} + +/home/git/gitlab-shell/gitlab-shell.log { + weekly + missingok + rotate 52 + compress + delaycompress + notifempty + copytruncate +} diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index f52b98cb3ae..573b076d60a 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -678,7 +678,7 @@ namespace :gitlab do end def sidekiq_process_match - run_and_match("ps ux | grep -i sidekiq", /(sidekiq \d+\.\d+\.\d+.+$)/) + run_and_match("ps ux | grep -i sidekiq | grep -v grep", /(sidekiq \d+\.\d+\.\d+.+$)/) end end diff --git a/lib/tasks/sidekiq.rake b/lib/tasks/sidekiq.rake index ba79b6e035d..23d41f8ed24 100644 --- a/lib/tasks/sidekiq.rake +++ b/lib/tasks/sidekiq.rake @@ -1,32 +1,19 @@ namespace :sidekiq do desc "GITLAB | Stop sidekiq" task :stop do - system "bundle exec sidekiqctl stop #{pidfile}" + system "script/background_jobs stop" end - desc "GITLAB | Start sidekiq" - task :start => :restart + desc "GITLAB | Start sidekiq" do + system "script/background_jobs start" + end - desc 'GitLab | Restart sidekiq' - task :restart do - if File.exist?(pidfile) - puts 'Shutting down existing sidekiq process.' - Rake::Task['sidekiq:stop'].invoke - puts 'Starting new sidekiq process.' - end - system "bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e #{Rails.env} -P #{pidfile} -d -L #{log_file} >> #{log_file} 2>&1" + desc 'GitLab | Restart sidekiq' do + system "script/background_jobs restart" end desc "GITLAB | Start sidekiq with launchd on Mac OS X" task :launchd do - system "bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e #{Rails.env} -P #{pidfile} >> #{log_file} 2>&1" - end - - def pidfile - Rails.root.join("tmp", "pids", "sidekiq.pid") - end - - def log_file - Rails.root.join("log", "sidekiq.log") + system "script/background_jobs start_no_deamonize" end end diff --git a/script/background_jobs b/script/background_jobs new file mode 100755 index 00000000000..e0beb3df815 --- /dev/null +++ b/script/background_jobs @@ -0,0 +1,56 @@ +#!/bin/bash + +cd $(dirname $0)/.. +app_root=$(pwd) +sidekiq_pidfile="$app_root/tmp/pids/sidekiq.pid" +sidekiq_logfile="$app_root/log/sidekiq.log" +gitlab_user=$(ls -l config.ru | awk '{print $3}') + +function stop +{ + bundle exec sidekiqctl stop $sidekiq_pidfile &>> $sidekiq_logfile +} + +function killall +{ + pkill -u $gitlab_user -f sidekiq +} + +function restart +{ + if [ -f $sidekiq_pidfile ]; then + stop + fi + killall + start_sidekiq -d -L $sidekiq_logfile +} + +function start_no_deamonize +{ + start_sidekiq +} + +function start_sidekiq +{ + bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e $RAILS_ENV -P $sidekiq_pidfile $@ &>> $sidekiq_logfile +} + +case "$1" in + stop) + stop + ;; + start) + restart + ;; + start_no_deamonize) + start_no_deamonize + ;; + restart) + restart + ;; + killall) + killall + ;; + *) + echo "Usage: RAILS_ENV=your_env $0 {stop|start|start_no_deamonize|restart|killall}" +esac diff --git a/script/web b/script/web new file mode 100755 index 00000000000..5464ed040aa --- /dev/null +++ b/script/web @@ -0,0 +1,49 @@ +#!/bin/bash + +cd $(dirname $0)/.. +app_root=$(pwd) + +unicorn_pidfile="$app_root/tmp/pids/unicorn.pid" +unicorn_config="$app_root/config/unicorn.rb" + +function get_unicorn_pid +{ + local pid=$(cat $unicorn_pidfile) + if [ -z $pid ] ; then + echo "Could not find a PID in $unicorn_pidfile" + exit 1 + fi + unicorn_pid=$pid +} + +function start +{ + bundle exec unicorn_rails -D -c $unicorn_config -E $RAILS_ENV +} + +function stop +{ + get_unicorn_pid + kill -QUIT $unicorn_pid +} + +function reload +{ + get_unicorn_pid + kill -USR2 $unicorn_pid +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + reload) + reload + ;; + *) + echo "Usage: RAILS_ENV=your_env $0 {start|stop|reload}" + ;; +esac |