Commit 067b2c06 authored by Patrick Bajao's avatar Patrick Bajao

Relax force pull mirror update restriction

We currently allow force pull mirror update via API and web UI if
the mirror wasn't updated within the last 5 minutes.

This affects pull mirrors that use SSH key authentication as they
will fail initially because the public key has to be added to the
source server. As a result, user have to wait 5 minutes before
they can retry. This also resulted to a QA spec to fail.

This change will fix it by not restricting force mirror updates
on mirrors that were never successfully updated.
parent df86ad56
......@@ -24,6 +24,8 @@ class StartPullMirroringService < BaseService
private
def update_now?(import_state)
import_state.last_update_at.nil? || import_state.last_update_at < INTERVAL.ago
import_state.last_successful_update_at.nil? ||
import_state.last_update_at.nil? ||
import_state.last_update_at < INTERVAL.ago
end
end
---
title: Relax force pull mirror update restriction
merge_request: 32075
author:
type: fixed
......@@ -32,7 +32,7 @@ describe StartPullMirroringService do
context 'when project mirror has been updated in the last 5 minutes' do
it 'schedules next execution' do
Timecop.freeze(Time.current) do
import_state.update(last_update_at: 3.minutes.ago)
import_state.update(last_update_at: 3.minutes.ago, last_successful_update_at: 10.minutes.ago)
expect { execute }
.to change { import_state.next_execution_timestamp }
......@@ -44,7 +44,15 @@ describe StartPullMirroringService do
context 'when project mirror has been updated more than 5 minutes ago' do
before do
import_state.update(last_update_at: 6.minutes.ago)
import_state.update(last_update_at: 6.minutes.ago, last_successful_update_at: 10.minutes.ago)
end
it_behaves_like 'force mirror update'
end
context 'when project mirror has been updated in the last 5 minutes but has never been successfully updated' do
before do
import_state.update(last_update_at: 3.minutes.ago, last_successful_update_at: nil)
end
it_behaves_like 'force mirror update'
......
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