Commit 5e077b0f authored by Nick Thomas's avatar Nick Thomas

Merge remote-tracking branch 'upstream/master' into ce-to-ee

parents 362aad89 b2884238
...@@ -7,7 +7,7 @@ module Projects ...@@ -7,7 +7,7 @@ module Projects
end end
def execute(new_repository_storage_key) def execute(new_repository_storage_key)
new_storage_path = Gitlab.config.repositories.storages[new_repository_storage_key] new_storage_path = Gitlab.config.repositories.storages[new_repository_storage_key]['path']
result = move_storage(project.path_with_namespace, new_storage_path) result = move_storage(project.path_with_namespace, new_storage_path)
if project.wiki.repository_exists? if project.wiki.repository_exists?
......
...@@ -20,20 +20,32 @@ def validate_storages_config ...@@ -20,20 +20,32 @@ def validate_storages_config
storage_validation_error("\"#{name}\" is not a valid storage name") unless storage_name_valid?(name) storage_validation_error("\"#{name}\" is not a valid storage name") unless storage_name_valid?(name)
if repository_storage.is_a?(String) if repository_storage.is_a?(String)
<<<<<<< HEAD
raise "#{name} is not a valid storage, because it has no `path` key. " \ raise "#{name} is not a valid storage, because it has no `path` key. " \
"It may be configured as:\n\n#{name}:\n path: #{repository_storage}\n\n" \ "It may be configured as:\n\n#{name}:\n path: #{repository_storage}\n\n" \
"For source installations, update your config/gitlab.yml Refer to gitlab.yml.example for an updated example.\n\n" \ "For source installations, update your config/gitlab.yml Refer to gitlab.yml.example for an updated example.\n\n" \
"If you're using the Gitlab Development Kit, you can update your configuration running `gdk reconfigure`.\n" "If you're using the Gitlab Development Kit, you can update your configuration running `gdk reconfigure`.\n"
=======
error = "#{name} is not a valid storage, because it has no `path` key. " \
"It may be configured as:\n\n#{name}:\n path: #{repository_storage}\n\n" \
"Refer to gitlab.yml.example for an updated example"
storage_validation_error(error)
>>>>>>> upstream/master
end end
if !repository_storage.is_a?(Hash) || repository_storage['path'].nil? if !repository_storage.is_a?(Hash) || repository_storage['path'].nil?
storage_validation_error("#{name} is not a valid storage, because it has no `path` key. Refer to gitlab.yml.example for an updated example") storage_validation_error("#{name} is not a valid storage, because it has no `path` key. Refer to gitlab.yml.example for an updated example")
end end
<<<<<<< HEAD
end end
end end
def validate_storages_paths def validate_storages_paths
Gitlab.config.repositories.storages.each do |name, repository_storage| Gitlab.config.repositories.storages.each do |name, repository_storage|
=======
>>>>>>> upstream/master
parent_name, _parent_path = find_parent_path(name, repository_storage['path']) parent_name, _parent_path = find_parent_path(name, repository_storage['path'])
if parent_name if parent_name
storage_validation_error("#{name} is a nested path of #{parent_name}. Nested paths are not supported for repository storages") storage_validation_error("#{name} is a nested path of #{parent_name}. Nested paths are not supported for repository storages")
......
...@@ -50,6 +50,7 @@ Update your current configuration as follows, replacing with your storages names ...@@ -50,6 +50,7 @@ Update your current configuration as follows, replacing with your storages names
}) })
``` ```
<<<<<<< HEAD
#### Git configuration #### Git configuration
Configure Git to generate packfile bitmaps (introduced in Git 2.0) on Configure Git to generate packfile bitmaps (introduced in Git 2.0) on
...@@ -61,6 +62,8 @@ cd /home/git/gitlab ...@@ -61,6 +62,8 @@ cd /home/git/gitlab
sudo -u git -H git config --global repack.writeBitmaps true sudo -u git -H git config --global repack.writeBitmaps true
``` ```
=======
>>>>>>> upstream/master
#### Nginx configuration #### Nginx configuration
Ensure you're still up-to-date with the latest NGINX configuration changes: Ensure you're still up-to-date with the latest NGINX configuration changes:
......
# From Community Edition 9.0 to Enterprise Edition 9.0
This guide assumes you have a correctly configured and tested installation of
GitLab Community Edition 9.0. If you run into any trouble or if you have any
questions please contact us at [support@gitlab.com].
### 0. Backup
Make a backup just in case something goes wrong:
```bash
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
```
For installations using MySQL, this may require granting "LOCK TABLES"
privileges to the GitLab user on the database version.
### 1. Stop server
```bash
sudo service gitlab stop
```
### 2. Get the EE code
```bash
cd /home/git/gitlab
sudo -u git -H git remote add -f ee https://gitlab.com/gitlab-org/gitlab-ee.git
sudo -u git -H git checkout 9-0-stable-ee
```
### 3. Install libs, migrations, etc.
```bash
cd /home/git/gitlab
# MySQL installations (note: the line below states '--without postgres')
sudo -u git -H bundle install --without postgres development test --deployment
# PostgreSQL installations (note: the line below states '--without mysql')
sudo -u git -H bundle install --without mysql development test --deployment
# Run database migrations
sudo -u git -H bundle exec rake db:migrate RAILS_ENV=production
# Clean up assets and cache
sudo -u git -H bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
```
### 4. Start application
```bash
sudo service gitlab start
sudo service nginx restart
```
### 5. Check application status
Check if GitLab and its environment are configured correctly:
```bash
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
```
To make sure you didn't miss anything run a more thorough check with:
```bash
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
```
If all items are green, then congratulations upgrade complete!
## Things went south? Revert to previous version (Community Edition 9.0)
### 1. Revert the code to the previous version
```bash
cd /home/git/gitlab
sudo -u git -H git checkout 9-0-stable
```
### 2. Restore from the backup
```bash
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:restore RAILS_ENV=production
```
[support@gitlab.com]: mailto:support@gitlab.com
...@@ -46,6 +46,7 @@ module Gitlab ...@@ -46,6 +46,7 @@ module Gitlab
services: Service.where(active: true).count, services: Service.where(active: true).count,
snippets: Snippet.count, snippets: Snippet.count,
todos: Todo.count, todos: Todo.count,
uploads: Upload.count,
web_hooks: WebHook.count web_hooks: WebHook.count
} }
} }
......
...@@ -48,9 +48,10 @@ namespace :gitlab do ...@@ -48,9 +48,10 @@ namespace :gitlab do
warn_user_is_not_gitlab warn_user_is_not_gitlab
remove_flag = ENV['REMOVE'] remove_flag = ENV['REMOVE']
Gitlab.config.repositories.storages.each do |name, repo_root| Gitlab.config.repositories.storages.each do |name, repository_storage|
repo_root = repository_storage['path'].chomp('/')
# Look for global repos (legacy, depth 1) and normal repos (depth 2) # Look for global repos (legacy, depth 1) and normal repos (depth 2)
IO.popen(%W(find #{repo_root.chomp('/')} -mindepth 1 -maxdepth 2 -name *+moved*.git)) do |find| IO.popen(%W(find #{repo_root} -mindepth 1 -maxdepth 2 -name *+moved*.git)) do |find|
find.each_line do |path| find.each_line do |path|
path.chomp! path.chomp!
if remove_flag if remove_flag
......
...@@ -12,6 +12,7 @@ describe '6_validations', lib: true do ...@@ -12,6 +12,7 @@ describe '6_validations', lib: true do
FileUtils.rm_rf('tmp/tests/paths') FileUtils.rm_rf('tmp/tests/paths')
end end
<<<<<<< HEAD
describe 'validate_storages_config' do describe 'validate_storages_config' do
context 'with correct settings' do context 'with correct settings' do
before do before do
...@@ -21,6 +22,11 @@ describe '6_validations', lib: true do ...@@ -21,6 +22,11 @@ describe '6_validations', lib: true do
it 'passes through' do it 'passes through' do
expect { validate_storages_config }.not_to raise_error expect { validate_storages_config }.not_to raise_error
end end
=======
context 'with correct settings' do
before do
mock_storages('foo' => { 'path' => 'tmp/tests/paths/a/b/c' }, 'bar' => { 'path' => 'tmp/tests/paths/a/b/d' })
>>>>>>> upstream/master
end end
context 'with invalid storage names' do context 'with invalid storage names' do
...@@ -33,6 +39,7 @@ describe '6_validations', lib: true do ...@@ -33,6 +39,7 @@ describe '6_validations', lib: true do
end end
end end
<<<<<<< HEAD
context 'with incomplete settings' do context 'with incomplete settings' do
before do before do
mock_storages('foo' => {}) mock_storages('foo' => {})
...@@ -41,6 +48,11 @@ describe '6_validations', lib: true do ...@@ -41,6 +48,11 @@ describe '6_validations', lib: true do
it 'throws an error suggesting the user to update its settings' do it 'throws an error suggesting the user to update its settings' do
expect { validate_storages_config }.to raise_error('foo is not a valid storage, because it has no `path` key. Refer to gitlab.yml.example for an updated example. Please fix this in your gitlab.yml before starting GitLab.') expect { validate_storages_config }.to raise_error('foo is not a valid storage, because it has no `path` key. Refer to gitlab.yml.example for an updated example. Please fix this in your gitlab.yml before starting GitLab.')
end end
=======
context 'with invalid storage names' do
before do
mock_storages('name with spaces' => { 'path' => 'tmp/tests/paths/a/b/c' })
>>>>>>> upstream/master
end end
context 'with deprecated settings structure' do context 'with deprecated settings structure' do
...@@ -54,17 +66,25 @@ describe '6_validations', lib: true do ...@@ -54,17 +66,25 @@ describe '6_validations', lib: true do
end end
end end
<<<<<<< HEAD
describe 'validate_storages_paths' do describe 'validate_storages_paths' do
context 'with correct settings' do context 'with correct settings' do
before do before do
mock_storages('foo' => { 'path' => 'tmp/tests/paths/a/b/c' }, 'bar' => { 'path' => 'tmp/tests/paths/a/b/d' }) mock_storages('foo' => { 'path' => 'tmp/tests/paths/a/b/c' }, 'bar' => { 'path' => 'tmp/tests/paths/a/b/d' })
end end
=======
context 'with nested storage paths' do
before do
mock_storages('foo' => { 'path' => 'tmp/tests/paths/a/b/c' }, 'bar' => { 'path' => 'tmp/tests/paths/a/b/c/d' })
end
>>>>>>> upstream/master
it 'passes through' do it 'passes through' do
expect { validate_storages_paths }.not_to raise_error expect { validate_storages_paths }.not_to raise_error
end end
end end
<<<<<<< HEAD
context 'with nested storage paths' do context 'with nested storage paths' do
before do before do
mock_storages('foo' => { 'path' => 'tmp/tests/paths/a/b/c' }, 'bar' => { 'path' => 'tmp/tests/paths/a/b/c/d' }) mock_storages('foo' => { 'path' => 'tmp/tests/paths/a/b/c' }, 'bar' => { 'path' => 'tmp/tests/paths/a/b/c/d' })
...@@ -73,6 +93,11 @@ describe '6_validations', lib: true do ...@@ -73,6 +93,11 @@ describe '6_validations', lib: true do
it 'throws an error' do it 'throws an error' do
expect { validate_storages_paths }.to raise_error('bar is a nested path of foo. Nested paths are not supported for repository storages. Please fix this in your gitlab.yml before starting GitLab.') expect { validate_storages_paths }.to raise_error('bar is a nested path of foo. Nested paths are not supported for repository storages. Please fix this in your gitlab.yml before starting GitLab.')
end end
=======
context 'with similar but un-nested storage paths' do
before do
mock_storages('foo' => { 'path' => 'tmp/tests/paths/a/b/c' }, 'bar' => { 'path' => 'tmp/tests/paths/a/b/c2' })
>>>>>>> upstream/master
end end
context 'with similar but un-nested storage paths' do context 'with similar but un-nested storage paths' do
...@@ -86,6 +111,26 @@ describe '6_validations', lib: true do ...@@ -86,6 +111,26 @@ describe '6_validations', lib: true do
end end
end end
context 'with incomplete settings' do
before do
mock_storages('foo' => {})
end
it 'throws an error suggesting the user to update its settings' do
expect { validate_storages }.to raise_error('foo is not a valid storage, because it has no `path` key. Refer to gitlab.yml.example for an updated example. Please fix this in your gitlab.yml before starting GitLab.')
end
end
context 'with deprecated settings structure' do
before do
mock_storages('foo' => 'tmp/tests/paths/a/b/c')
end
it 'throws an error suggesting the user to update its settings' do
expect { validate_storages }.to raise_error("foo is not a valid storage, because it has no `path` key. It may be configured as:\n\nfoo:\n path: tmp/tests/paths/a/b/c\n\nRefer to gitlab.yml.example for an updated example. Please fix this in your gitlab.yml before starting GitLab.")
end
end
def mock_storages(storages) def mock_storages(storages)
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end end
......
...@@ -61,6 +61,7 @@ describe Gitlab::UsageData do ...@@ -61,6 +61,7 @@ describe Gitlab::UsageData do
services services
snippets snippets
todos todos
uploads
web_hooks web_hooks
)) ))
end end
......
...@@ -1964,9 +1964,14 @@ describe Project, models: true do ...@@ -1964,9 +1964,14 @@ describe Project, models: true do
storages = { storages = {
'a' => { 'path' => 'tmp/tests/storage_a' }, 'a' => { 'path' => 'tmp/tests/storage_a' },
<<<<<<< HEAD
'b' => { 'path' => 'tmp/tests/storage_b' }, 'b' => { 'path' => 'tmp/tests/storage_b' },
} }
=======
'b' => { 'path' => 'tmp/tests/storage_b' }
}
>>>>>>> upstream/master
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end end
......
...@@ -11,7 +11,10 @@ describe Projects::UpdateRepositoryStorageService, services: true do ...@@ -11,7 +11,10 @@ describe Projects::UpdateRepositoryStorageService, services: true do
FileUtils.mkdir('tmp/tests/storage_a') FileUtils.mkdir('tmp/tests/storage_a')
FileUtils.mkdir('tmp/tests/storage_b') FileUtils.mkdir('tmp/tests/storage_b')
storages = { 'a' => 'tmp/tests/storage_a', 'b' => 'tmp/tests/storage_b' } storages = {
'a' => { 'path' => 'tmp/tests/storage_a' },
'b' => { 'path' => 'tmp/tests/storage_b' }
}
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
allow(subject).to receive(:gitlab_shell).and_return(gitlab_shell) allow(subject).to receive(:gitlab_shell).and_return(gitlab_shell)
......
...@@ -107,9 +107,14 @@ describe Projects::UpdateService, services: true do ...@@ -107,9 +107,14 @@ describe Projects::UpdateService, services: true do
storages = { storages = {
'a' => { 'path' => 'tmp/tests/storage_a' }, 'a' => { 'path' => 'tmp/tests/storage_a' },
<<<<<<< HEAD
'b' => { 'path' => 'tmp/tests/storage_b' }, 'b' => { 'path' => 'tmp/tests/storage_b' },
} }
=======
'b' => { 'path' => 'tmp/tests/storage_b' }
}
>>>>>>> upstream/master
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment