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,10 +96,24 @@ module Projects ...@@ -96,10 +96,24 @@ module Projects
.rename_project(path_before, project_path, namespace_full_path) .rename_project(path_before, project_path, namespace_full_path)
end end
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 Gitlab::PagesTransfer
.new .new
.rename_project(path_before, project_path, namespace_full_path) .rename_project(path_before, project_path, namespace_full_path)
end end
end
def log_completion def log_completion
Gitlab::AppLogger.info( Gitlab::AppLogger.info(
......
---
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,16 +62,26 @@ RSpec.describe Projects::AfterRenameService do ...@@ -62,16 +62,26 @@ 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 end
context 'when async_pages_move_project_rename is disabled' do
it 'moves pages folder to new location' 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) expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project)
service_execute service_execute
end end
end end
it 'schedules a move of the pages directory' do
expect(PagesTransferWorker).to receive(:perform_async).with('rename_project', anything)
service_execute
end
end
context 'attachments' do context 'attachments' do
before do before do
expect(project_storage).to receive(:rename_repo) { true } expect(project_storage).to receive(:rename_repo) { true }
...@@ -160,13 +170,23 @@ RSpec.describe Projects::AfterRenameService do ...@@ -160,13 +170,23 @@ RSpec.describe Projects::AfterRenameService do
end end
context 'gitlab pages' do context 'gitlab pages' do
context 'when async_pages_move_project_rename is disabled' do
it 'moves pages folder to new location' 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) expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project)
service_execute service_execute
end end
end end
it 'schedules a move of the pages directory' do
expect(PagesTransferWorker).to receive(:perform_async).with('rename_project', anything)
service_execute
end
end
context 'attachments' do context 'attachments' do
let(:uploader) { create(:upload, :issuable_upload, :with_file, model: project) } let(:uploader) { create(:upload, :issuable_upload, :with_file, model: project) }
let(:file_uploader) { build(:file_uploader, project: project) } let(:file_uploader) { build(:file_uploader, project: project) }
......
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