Commit df2052b5 authored by Stan Hu's avatar Stan Hu

Merge branch 'allow-pages-namespace-move-async' into 'master'

Put Pages moves from namespace renames and transfers in Sidekiq

See merge request gitlab-org/gitlab!40259
parents 89191a33 b65a721e
......@@ -23,10 +23,26 @@ module Storage
former_parent_full_path = parent_was&.full_path
parent_full_path = parent&.full_path
Gitlab::UploadsTransfer.new.move_namespace(path, former_parent_full_path, parent_full_path)
Gitlab::PagesTransfer.new.move_namespace(path, former_parent_full_path, parent_full_path)
if ::Feature.enabled?(:async_pages_move_namespace_transfer, self)
run_after_commit do
Gitlab::PagesTransfer.new.async.move_namespace(path, former_parent_full_path, parent_full_path)
end
else
Gitlab::PagesTransfer.new.move_namespace(path, former_parent_full_path, parent_full_path)
end
else
Gitlab::UploadsTransfer.new.rename_namespace(full_path_before_last_save, full_path)
Gitlab::PagesTransfer.new.rename_namespace(full_path_before_last_save, full_path)
if ::Feature.enabled?(:async_pages_move_namespace_rename, self)
full_path_was = full_path_before_last_save
run_after_commit do
Gitlab::PagesTransfer.new.async.rename_namespace(full_path_was, full_path)
end
else
Gitlab::PagesTransfer.new.rename_namespace(full_path_before_last_save, full_path)
end
end
# If repositories moved successfully we need to
......
---
name: async_pages_move_namespace_rename
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40259
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/235808
group: team::Scalability
type: development
default_enabled: false
---
name: async_pages_move_namespace_transfer
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40259
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/235808
group: team::Scalability
type: development
default_enabled: false
......@@ -407,8 +407,26 @@ RSpec.describe Namespace do
FileUtils.mkdir_p(File.join(pages_dir, project.full_path))
end
after do
FileUtils.remove_entry(File.join(TestEnv.repos_path, parent.full_path), true)
FileUtils.remove_entry(File.join(TestEnv.repos_path, new_parent.full_path), true)
FileUtils.remove_entry(File.join(TestEnv.repos_path, child.full_path), true)
FileUtils.remove_entry(File.join(uploads_dir, project.full_path), true)
FileUtils.remove_entry(File.join(pages_dir, project.full_path), true)
end
context 'renaming child' do
it 'correctly moves the repository, uploads and pages' do
context 'when async_pages_move_namespace_rename is disabled' do
it 'correctly moves the repository, uploads and pages' do
stub_feature_flags(async_pages_move_namespace_rename: false)
child.update!(path: 'renamed')
expect_project_directories_at('parent/renamed')
end
end
it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
child.update!(path: 'renamed')
expect_project_directories_at('parent/renamed')
......@@ -416,7 +434,17 @@ RSpec.describe Namespace do
end
context 'renaming parent' do
it 'correctly moves the repository, uploads and pages' do
context 'when async_pages_move_namespace_rename is disabled' do
it 'correctly moves the repository, uploads and pages' do
stub_feature_flags(async_pages_move_namespace_rename: false)
parent.update!(path: 'renamed')
expect_project_directories_at('renamed/child')
end
end
it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
parent.update!(path: 'renamed')
expect_project_directories_at('renamed/child')
......@@ -424,7 +452,17 @@ RSpec.describe Namespace do
end
context 'moving from one parent to another' do
it 'correctly moves the repository, uploads and pages' do
context 'when async_pages_move_namespace_transfer is disabled' do
it 'correctly moves the repository, uploads and pages' do
stub_feature_flags(async_pages_move_namespace_transfer: false)
child.update!(parent: new_parent)
expect_project_directories_at('new_parent/child')
end
end
it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
child.update!(parent: new_parent)
expect_project_directories_at('new_parent/child')
......@@ -432,7 +470,17 @@ RSpec.describe Namespace do
end
context 'moving from having a parent to root' do
it 'correctly moves the repository, uploads and pages' do
context 'when async_pages_move_namespace_transfer is disabled' do
it 'correctly moves the repository, uploads and pages' do
stub_feature_flags(async_pages_move_namespace_transfer: false)
child.update!(parent: nil)
expect_project_directories_at('child')
end
end
it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
child.update!(parent: nil)
expect_project_directories_at('child')
......@@ -440,7 +488,17 @@ RSpec.describe Namespace do
end
context 'moving from root to having a parent' do
it 'correctly moves the repository, uploads and pages' do
context 'when async_pages_move_namespace_transfer is disabled' do
it 'correctly moves the repository, uploads and pages' do
stub_feature_flags(async_pages_move_namespace_transfer: false)
parent.update!(parent: new_parent)
expect_project_directories_at('new_parent/parent/child')
end
end
it 'correctly moves the repository, uploads and pages', :sidekiq_inline do
parent.update!(parent: new_parent)
expect_project_directories_at('new_parent/parent/child')
......
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