Commit b5975c65 authored by Sean McGivern's avatar Sean McGivern

Move Pages directory in Sidekiq when renaming a project

This is behind the async_pages_move_project_rename feature flag. When
it's enabled and a project is renamed, we do not move the Pages
directory in Puma - instead, we schedule a Sidekiq job to perform the
move.

We already weren't checking the return value of
`Gitlab::PagesTransfer#rename_project`, so this shouldn't introduce any
failure cases that weren't there already.
parent 0fb3f3a8
......@@ -96,9 +96,23 @@ module Projects
.rename_project(path_before, project_path, namespace_full_path)
end
Gitlab::PagesTransfer
.new
.rename_project(path_before, project_path, namespace_full_path)
if ::Feature.enabled?(:async_pages_move_project_rename, project)
# Block will be evaluated in the context of project so we need
# to bind to a local variable to capture it, as the instance
# variable and method aren't available on Project
path_before_local = @path_before
project.run_after_commit_or_now do
Gitlab::PagesTransfer
.new
.async
.rename_project(path_before_local, path, namespace.full_path)
end
else
Gitlab::PagesTransfer
.new
.rename_project(path_before, project_path, namespace_full_path)
end
end
def log_completion
......
---
name: async_pages_move_project_rename
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40087
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/235802
group: team::Scalability
type: development
default_enabled: false
......@@ -62,11 +62,21 @@ RSpec.describe Projects::AfterRenameService do
context 'gitlab pages' do
before do
expect(project_storage).to receive(:rename_repo) { true }
allow(project_storage).to receive(:rename_repo) { true }
end
context 'when async_pages_move_project_rename is disabled' do
it 'moves pages folder to new location' do
stub_feature_flags(async_pages_move_project_rename: false)
expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project)
service_execute
end
end
it 'moves pages folder to new location' do
expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project)
it 'schedules a move of the pages directory' do
expect(PagesTransferWorker).to receive(:perform_async).with('rename_project', anything)
service_execute
end
......@@ -160,8 +170,18 @@ RSpec.describe Projects::AfterRenameService do
end
context 'gitlab pages' do
it 'moves pages folder to new location' do
expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project)
context 'when async_pages_move_project_rename is disabled' do
it 'moves pages folder to new location' do
stub_feature_flags(async_pages_move_project_rename: false)
expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project)
service_execute
end
end
it 'schedules a move of the pages directory' do
expect(PagesTransferWorker).to receive(:perform_async).with('rename_project', anything)
service_execute
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