Skip to content
Snippets Groups Projects
Commit d892e80b authored by Robert Speicher's avatar Robert Speicher
Browse files

Merge branch 'bvl-mark-remote-mirrors-as-failed-sooner' into 'master'

Mark mirrors as failed 1 hour after they started

See merge request gitlab-org/gitlab-ce!30999
parents 2eda97be ab11eee1
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -31,7 +31,7 @@ class RemoteMirror < ApplicationRecord
 
scope :enabled, -> { where(enabled: true) }
scope :started, -> { with_update_status(:started) }
scope :stuck, -> { started.where('last_update_at < ? OR (last_update_at IS NULL AND updated_at < ?)', 1.day.ago, 1.day.ago) }
scope :stuck, -> { started.where('last_update_at < ? OR (last_update_at IS NULL AND updated_at < ?)', 1.hour.ago, 3.hours.ago) }
 
state_machine :update_status, initial: :none do
event :update_start do
Loading
Loading
@@ -173,7 +173,7 @@ class RemoteMirror < ApplicationRecord
 
result = URI.parse(url)
result.password = '*****' if result.password
result.user = '*****' if result.user && result.user != "git" # tokens or other data may be saved as user
result.user = '*****' if result.user && result.user != 'git' # tokens or other data may be saved as user
result.to_s
end
 
Loading
Loading
---
title: Mark push mirrors as failed after 1 hour
merge_request: 30999
author:
type: changed
Loading
Loading
@@ -113,7 +113,7 @@ describe RemoteMirror, :mailer do
 
remote_mirror = create(:remote_mirror)
 
expect(remote_mirror.remote_name).to eq("remote_mirror_secret")
expect(remote_mirror.remote_name).to eq('remote_mirror_secret')
end
end
 
Loading
Loading
@@ -201,11 +201,20 @@ describe RemoteMirror, :mailer do
end
 
context 'stuck mirrors' do
it 'includes mirrors stuck in started with no last_update_at set' do
it 'includes mirrors that were started over an hour ago' do
mirror = create_mirror(url: 'http://cantbeblank',
update_status: 'started',
last_update_at: 3.hours.ago,
updated_at: 2.hours.ago)
expect(described_class.stuck.last).to eq(mirror)
end
it 'includes mirrors started over 3 hours ago for their first sync' do
mirror = create_mirror(url: 'http://cantbeblank',
update_status: 'started',
last_update_at: nil,
updated_at: 25.hours.ago)
updated_at: 4.hours.ago)
 
expect(described_class.stuck.last).to eq(mirror)
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment