Commit 2d2c108d authored by Bob Van Landuyt's avatar Bob Van Landuyt

Prioritize CI mirrors

By setting the next execution time in the past, they will be
prioritized before any other mirrors.
parent aba8053b
......@@ -150,7 +150,7 @@ module EE
def force_import_job!
return if mirror_update_due? || updating_mirror?
set_next_execution_to_now
set_next_execution_to_now(prioritized: true)
reset_retry_count if hard_failed?
save!
......@@ -158,10 +158,10 @@ module EE
UpdateAllMirrorsWorker.perform_async
end
def set_next_execution_to_now
def set_next_execution_to_now(prioritized: false)
return unless mirror?
self.next_execution_timestamp = Time.now
self.next_execution_timestamp = prioritized ? 5.minutes.ago : Time.now
end
def retry_limit_exceeded?
......
---
title: Prioritize mirrors for CI over other mirrors
merge_request: 14575
author:
type: changed
# frozen_string_literal: true
require 'rails_helper'
describe ProjectImportState, type: :model do
......@@ -441,14 +443,14 @@ describe ProjectImportState, type: :model do
expect(import_state.force_import_job!).to be_nil
end
it 'sets next execution timestamp to now and schedules UpdateAllMirrorsWorker' do
timestamp = 1.second.from_now.change(usec: 0)
it 'sets next execution timestamp to 5 minutes ago and schedules UpdateAllMirrorsWorker' do
timestamp = Time.now
import_state = create(:import_state, :mirror)
expect(UpdateAllMirrorsWorker).to receive(:perform_async)
Timecop.freeze(timestamp) do
expect { import_state.force_import_job! }.to change(import_state, :next_execution_timestamp).to(timestamp)
expect { import_state.force_import_job! }.to change(import_state, :next_execution_timestamp).to(5.minutes.ago)
end
end
......@@ -461,7 +463,7 @@ describe ProjectImportState, type: :model do
Timecop.freeze(timestamp) do
expect { import_state.force_import_job! }.to change(import_state, :retry_count).to(0)
expect(import_state.next_execution_timestamp).to be_like_time(timestamp)
expect(import_state.next_execution_timestamp).to be_like_time(5.minutes.ago)
end
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