Commit 469eb8ed authored by James Lopez's avatar James Lopez

fix remote mirror stuck on started issue

parent 5a688e4f
...@@ -34,7 +34,7 @@ class RemoteMirror < ActiveRecord::Base ...@@ -34,7 +34,7 @@ class RemoteMirror < ActiveRecord::Base
scope :enabled, -> { where(enabled: true) } scope :enabled, -> { where(enabled: true) }
scope :started, -> { with_update_status(:started) } scope :started, -> { with_update_status(:started) }
scope :stuck, -> { started.where('last_update_at < ?', 1.day.ago) } scope :stuck, -> { started.where('last_update_at < ? OR (last_update_at IS NULL AND updated_at < ?)', 1.day.ago, 1.day.ago) }
state_machine :update_status, initial: :none do state_machine :update_status, initial: :none do
event :update_start do event :update_start do
......
...@@ -18,7 +18,7 @@ module Projects ...@@ -18,7 +18,7 @@ module Projects
push_tags if changed_tags.present? push_tags if changed_tags.present?
delete_tags if deleted_tags.present? delete_tags if deleted_tags.present?
rescue Gitlab::Shell::Error => e rescue => e
errors << e.message.strip errors << e.message.strip
end end
......
...@@ -43,6 +43,15 @@ describe RemoteMirror do ...@@ -43,6 +43,15 @@ describe RemoteMirror do
expect(mirror.url).to eq('http://foo:bar@test.com') expect(mirror.url).to eq('http://foo:bar@test.com')
expect(mirror.credentials).to eq({ user: 'foo', password: 'bar' }) expect(mirror.credentials).to eq({ user: 'foo', password: 'bar' })
end end
it 'should still be picked up by the worker if is stuck' do
mirror = create_mirror_with_url('http://test.com')
mirror.update_attribute(:update_status, 'started')
# this will reset some of the updated_at fields
mirror.update_attribute(:url, 'http://foo:bar@test.com')
expect(RemoteMirror.stuck.last).to eq(mirror)
end
end 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