Commit a23c648d authored by John Cai's avatar John Cai Committed by Rémy Coutable

Only move repos for legacy project storage

parent 3dbb2de4
...@@ -55,7 +55,7 @@ module Storage ...@@ -55,7 +55,7 @@ module Storage
def move_repositories def move_repositories
# Move the namespace directory in all storages used by member projects # Move the namespace directory in all storages used by member projects
repository_storages.each do |repository_storage| repository_storages(legacy_only: true).each do |repository_storage|
# Ensure old directory exists before moving it # Ensure old directory exists before moving it
gitlab_shell.add_namespace(repository_storage, full_path_before_last_save) gitlab_shell.add_namespace(repository_storage, full_path_before_last_save)
...@@ -77,12 +77,14 @@ module Storage ...@@ -77,12 +77,14 @@ module Storage
@old_repository_storage_paths ||= repository_storages @old_repository_storage_paths ||= repository_storages
end end
def repository_storages def repository_storages(legacy_only: false)
# We need to get the storage paths for all the projects, even the ones that are # We need to get the storage paths for all the projects, even the ones that are
# pending delete. Unscoping also get rids of the default order, which causes # pending delete. Unscoping also get rids of the default order, which causes
# problems with SELECT DISTINCT. # problems with SELECT DISTINCT.
Project.unscoped do Project.unscoped do
all_projects.select('distinct(repository_storage)').to_a.map(&:repository_storage) namespace_projects = all_projects
namespace_projects = namespace_projects.without_storage_feature(:repository) if legacy_only
namespace_projects.pluck(Arel.sql('distinct(repository_storage)'))
end end
end end
......
---
title: Only move repos for legacy project storage
merge_request: 19410
author:
type: fixed
...@@ -281,6 +281,44 @@ describe Namespace do ...@@ -281,6 +281,44 @@ describe Namespace do
end end
end end
shared_examples 'move_dir without repository storage feature' do |storage_version|
let(:namespace) { create(:namespace) }
let(:gitlab_shell) { namespace.gitlab_shell }
let!(:project) { create(:project_empty_repo, namespace: namespace, storage_version: storage_version) }
it 'calls namespace service' do
expect(gitlab_shell).to receive(:add_namespace).and_return(true)
expect(gitlab_shell).to receive(:mv_namespace).and_return(true)
namespace.move_dir
end
end
shared_examples 'move_dir with repository storage feature' do |storage_version|
let(:namespace) { create(:namespace) }
let(:gitlab_shell) { namespace.gitlab_shell }
let!(:project) { create(:project_empty_repo, namespace: namespace, storage_version: storage_version) }
it 'does not call namespace service' do
expect(gitlab_shell).not_to receive(:add_namespace)
expect(gitlab_shell).not_to receive(:mv_namespace)
namespace.move_dir
end
end
context 'project is without repository storage feature' do
[nil, 0].each do |storage_version|
it_behaves_like 'move_dir without repository storage feature', storage_version
end
end
context 'project has repository storage feature' do
[1, 2].each do |storage_version|
it_behaves_like 'move_dir with repository storage feature', storage_version
end
end
context 'with subgroups' do context 'with subgroups' do
let(:parent) { create(:group, name: 'parent', path: 'parent') } let(:parent) { create(:group, name: 'parent', path: 'parent') }
let(:new_parent) { create(:group, name: 'new_parent', path: 'new_parent') } let(:new_parent) { create(:group, name: 'new_parent', path: 'new_parent') }
......
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