Commit 1b74918a authored by Tiago Botelho's avatar Tiago Botelho

Forces import worker with mirror to insert mirror in front of queue

parent ac44a89e
...@@ -26,9 +26,9 @@ class RepositoryImportWorker ...@@ -26,9 +26,9 @@ class RepositoryImportWorker
project.repository.after_import project.repository.after_import
project.import_finish project.import_finish
# Explicitly schedule mirror for update so # Explicitly enqueue mirror for update so
# that upstream remote is created and fetched # that upstream remote is created and fetched
project.import_schedule if project.mirror? project.force_import_job! if project.mirror?
rescue ImportError => ex rescue ImportError => ex
fail_import(project, ex.message) fail_import(project, ex.message)
raise raise
......
...@@ -15,8 +15,9 @@ class UpdateAllMirrorsWorker ...@@ -15,8 +15,9 @@ class UpdateAllMirrorsWorker
fail_stuck_mirrors! fail_stuck_mirrors!
return if Gitlab::Mirror.max_mirror_capacity_reached? unless Gitlab::Mirror.max_mirror_capacity_reached?
Project.mirrors_to_sync.find_each(batch_size: 200, &:import_schedule) Project.mirrors_to_sync.find_each(batch_size: 200, &:import_schedule)
end
cancel_lease(lease_uuid) cancel_lease(lease_uuid)
end end
......
---
title: Forces import worker with mirror to insert mirror in front of queue
merge_request: 2231
author:
...@@ -1744,9 +1744,9 @@ describe Project, models: true do ...@@ -1744,9 +1744,9 @@ describe Project, models: true do
context 'with a mirrored project' do context 'with a mirrored project' do
let(:project) { create(:empty_project, :mirror) } let(:project) { create(:empty_project, :mirror) }
it 'first calls RepositoryImportWorker and RepositoryUpdateMirrorWorker after' do it 'calls RepositoryImportWorker and inserts in front of the mirror scheduler queue' do
allow_any_instance_of(Project).to receive(:repository_exists?).and_return(false, true) allow_any_instance_of(Project).to receive(:repository_exists?).and_return(false, true)
expect_any_instance_of(RepositoryUpdateMirrorWorker).to receive(:perform).with(project.id) expect_any_instance_of(EE::Project).to receive(:force_import_job!)
expect_any_instance_of(RepositoryImportWorker).to receive(:perform).with(project.id).and_call_original expect_any_instance_of(RepositoryImportWorker).to receive(:perform).with(project.id).and_call_original
project.import_schedule project.import_schedule
......
...@@ -18,6 +18,19 @@ describe RepositoryImportWorker do ...@@ -18,6 +18,19 @@ describe RepositoryImportWorker do
end end
end end
context 'when project is a mirror' do
let(:project) { create(:empty_project, :mirror, :import_scheduled) }
it 'adds mirror in front of the mirror scheduler queue' do
expect_any_instance_of(Projects::ImportService).to receive(:execute)
.and_return({ status: :ok })
expect_any_instance_of(EE::Project).to receive(:force_import_job!)
subject.perform(project.id)
end
end
context 'when the import has failed' do context 'when the import has failed' do
it 'hide the credentials that were used in the import URL' do it 'hide the credentials that were used in the import URL' do
error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found } error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found }
......
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