Commit 247b55db authored by Sean McGivern's avatar Sean McGivern

Merge branch 'bvl-async-move-pages-project-transfer' into 'master'

Move pages async when transferring project

See merge request gitlab-org/gitlab!40492
parents 010a6c87 e75847ce
......@@ -88,15 +88,14 @@ module Projects
# Move uploads
move_project_uploads(project)
# Move pages
Gitlab::PagesTransfer.new.move_project(project.path, @old_namespace.full_path, @new_namespace.full_path)
project.old_path_with_namespace = @old_path
update_repository_configuration(@new_path)
execute_system_hooks
end
move_pages(project)
rescue Exception # rubocop:disable Lint/RescueException
rollback_side_effects
raise
......@@ -181,6 +180,19 @@ module Projects
)
end
def move_pages(project)
transfer = Gitlab::PagesTransfer.new
if Feature.enabled?(:async_pages_move_project_transfer, project)
# Avoid scheduling moves for directories that don't exist.
return unless project.pages_deployed?
transfer = transfer.async
end
transfer.move_project(project.path, @old_namespace.full_path, @new_namespace.full_path)
end
def old_wiki_repo_path
"#{old_path}#{::Gitlab::GlRepository::WIKI.path_suffix}"
end
......
---
name: async_pages_move_project_transfer
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40492
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/235757
group: team::Scalability
type: development
default_enabled: false
......@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe Projects::TransferService do
include GitHelpers
let(:user) { create(:user) }
let(:group) { create(:group) }
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let(:project) { create(:project, :repository, :legacy_storage, namespace: user.namespace) }
subject(:execute_transfer) { described_class.new(project, user).execute(group) }
......@@ -489,6 +489,43 @@ RSpec.describe Projects::TransferService do
end
end
context 'moving pages' do
let_it_be(:project) { create(:project, namespace: user.namespace) }
before do
group.add_owner(user)
end
it 'schedules a job when pages are deployed' do
project.mark_pages_as_deployed
expect(PagesTransferWorker).to receive(:perform_async)
.with("move_project", [project.path, user.namespace.full_path, group.full_path])
execute_transfer
end
it 'does not schedule a job when no pages are deployed' do
expect(PagesTransferWorker).not_to receive(:perform_async)
execute_transfer
end
context 'when async_pages_move_project_transfer is disabled' do
before do
stub_feature_flags(async_pages_move_project_transfer: false)
end
it 'moves pages inline' do
expect_next_instance_of(Gitlab::PagesTransfer) do |transfer|
expect(transfer).to receive(:move_project).with(project.path, user.namespace.full_path, group.full_path)
end
execute_transfer
end
end
end
def rugged_config
rugged_repo(project.repository).config
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