Commit 9ad2df75 authored by James Lopez's avatar James Lopez

Merge branch 'allow-pages-project-rename-async' into 'master'

Move Pages directory in Sidekiq when renaming a project

See merge request gitlab-org/gitlab!40087
parents 424187fa b5975c65
...@@ -96,9 +96,23 @@ module Projects ...@@ -96,9 +96,23 @@ module Projects
.rename_project(path_before, project_path, namespace_full_path) .rename_project(path_before, project_path, namespace_full_path)
end end
Gitlab::PagesTransfer if ::Feature.enabled?(:async_pages_move_project_rename, project)
.new # Block will be evaluated in the context of project so we need
.rename_project(path_before, project_path, namespace_full_path) # 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 end
def log_completion 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 ...@@ -62,11 +62,21 @@ RSpec.describe Projects::AfterRenameService do
context 'gitlab pages' do context 'gitlab pages' do
before 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 end
it 'moves pages folder to new location' do it 'schedules a move of the pages directory' do
expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project) expect(PagesTransferWorker).to receive(:perform_async).with('rename_project', anything)
service_execute service_execute
end end
...@@ -160,8 +170,18 @@ RSpec.describe Projects::AfterRenameService do ...@@ -160,8 +170,18 @@ RSpec.describe Projects::AfterRenameService do
end end
context 'gitlab pages' do context 'gitlab pages' do
it 'moves pages folder to new location' do context 'when async_pages_move_project_rename is disabled' do
expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project) 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 service_execute
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