Commit 9e660d3f authored by Douwe Maan's avatar Douwe Maan

Merge branch 'stuck_mirrors_check' into 'master'

Decrease maximum time to wait for a mirror process to finish from 1 day to 2 hours

This MR proposes to decrease the time that GitLab waits before to mark a mirror update process stuck as `failed`.  
Full description of the scenario in #1093  
Now this time is one day. When the problem happens, the user sees during one day that the project was updating from upstream.  
If a project has been updating from a remote for longer than 2 hours, we could conclude that something went wrong, mark the mirror as `failed` and retry next time.

Closes #1093

See merge request !791
parents e6ec9645 363ef815
......@@ -4,6 +4,7 @@ v 8.13.0 (unreleased)
- Fix 500 error updating mirror URLs for projects
- Fix validations related to mirroring settings form. !773
- Fix Git access panel for Wikis when Kerberos authentication is enabled (Borja Aparicio)
- Decrease maximum time that GitLab waits for a mirror to finish !791 (Borja Aparicio)
v 8.12.5
- No EE-specific changes
......
......@@ -16,7 +16,7 @@ class UpdateAllMirrorsWorker
def fail_stuck_mirrors!
stuck = Project.mirror.
with_import_status(:started).
where('mirror_last_update_at < ?', 1.day.ago)
where('mirror_last_update_at < ?', 2.hours.ago)
stuck.find_each(batch_size: 50) do |project|
project.mark_import_as_failed('The mirror update took too long to complete.')
......
......@@ -42,7 +42,7 @@ describe UpdateAllMirrorsWorker do
describe '#fail_stuck_mirrors!' do
it 'ignores records that are not mirrors' do
create(:empty_project, :import_started, mirror_last_update_at: 3.days.ago)
create(:empty_project, :import_started, mirror_last_update_at: 12.hours.ago)
expect_any_instance_of(Project).not_to receive(:import_fail)
......@@ -50,7 +50,7 @@ describe UpdateAllMirrorsWorker do
end
it 'ignores records without in-progress import' do
create(:empty_project, :mirror, :import_finished, mirror_last_update_at: 3.days.ago)
create(:empty_project, :mirror, :import_finished, mirror_last_update_at: 12.hours.ago)
expect_any_instance_of(Project).not_to receive(:import_fail)
......@@ -66,7 +66,7 @@ describe UpdateAllMirrorsWorker do
end
it 'transitions stuck mirrors to a failed state' do
project = create(:empty_project, :mirror, mirror_last_update_at: 3.days.ago)
project = create(:empty_project, :mirror, mirror_last_update_at: 12.hours.ago)
perform
project.reload
......@@ -75,7 +75,7 @@ describe UpdateAllMirrorsWorker do
end
it 'updates the import_error message' do
project = create(:empty_project, :mirror, mirror_last_update_at: 3.days.ago)
project = create(:empty_project, :mirror, mirror_last_update_at: 12.hours.ago)
perform
project.reload
......
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