Commit b65a721e authored by Sean McGivern's avatar Sean McGivern

Put Pages moves from namespace transfers in Sidekiq

This is the same as the previous commit, but when a namespace changes
its parent namespace via a transfer. (The previous commit is for a
namespace changing its own path directly.) We're moving Pages disk
operations from Puma to Sidekiq, and here that's behind the
`async_pages_move_namespace_transfer` feature flag.
parent 607ec3ea
......@@ -23,7 +23,14 @@ 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)
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)
......
---
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
......@@ -409,6 +409,8 @@ RSpec.describe Namespace do
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
......@@ -450,7 +452,17 @@ RSpec.describe Namespace do
end
context 'moving from one parent to another' 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')
......@@ -458,7 +470,17 @@ RSpec.describe Namespace do
end
context 'moving from having a parent to root' 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')
......@@ -466,7 +488,17 @@ RSpec.describe Namespace do
end
context 'moving from root to having a parent' 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