Commit 0d86c492 authored by Stan Hu's avatar Stan Hu

Merge branch '5533-geo-automatically-clean-up-stale-lock-files-on-geo-secondary' into 'master'

Resolve "Geo: Automatically clean up stale lock files on Geo secondary"

Closes #5533

See merge request gitlab-org/gitlab-ee!6034
parents 6d7c3053 7c8fe2ec
......@@ -167,8 +167,9 @@ module Geo
attrs["resync_#{type}"] = true
attrs["last_#{type}_sync_failure"] = "#{message}: #{error.message}"
attrs["#{type}_retry_count"] = retry_count + 1
registry.update!(attrs)
repository.clean_stale_repository_files
end
def type
......
---
title: 'Geo: Automatically clean up stale lock files on Geo secondary'
merge_request: 6034
author:
type: fixed
......@@ -224,28 +224,23 @@ describe Geo::RepositorySyncService do
allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true)
.and_raise(Gitlab::Shell::Error.new('shell error'))
subject.execute
end
it 'sets last_repository_synced_at' do
expect(registry.last_repository_synced_at).not_to be_nil
end
it 'resets last_repository_successful_sync_at' do
expect(registry.last_repository_successful_sync_at).to be_nil
end
it 'sets correct values for registry record' do
subject.execute
it 'resets repository_retry_count' do
expect(registry.repository_retry_count).to eq(1)
expect(registry).to have_attributes(last_repository_synced_at: be_present,
last_repository_successful_sync_at: nil,
repository_retry_count: 1,
repository_retry_at: be_present,
last_repository_sync_failure: 'Error syncing repository: shell error'
)
end
it 'resets repository_retry_at' do
expect(registry.repository_retry_at).to be_present
end
it 'calls repository cleanup' do
expect(repository).to receive(:clean_stale_repository_files)
it 'sets last_repository_sync_failure' do
expect(registry.last_repository_sync_failure).to eq('Error syncing repository: shell error')
subject.execute
end
end
end
......
......@@ -184,20 +184,21 @@ RSpec.describe Geo::WikiSyncService do
allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true)
.and_raise(Gitlab::Shell::Error.new('shell error'))
end
it 'sets correct values for registry record' do
subject.execute
end
it 'sets last_wiki_synced_at' do
expect(registry.last_wiki_synced_at).not_to be_nil
expect(registry).to have_attributes(last_wiki_synced_at: be_present,
last_wiki_successful_sync_at: nil,
last_wiki_sync_failure: 'Error syncing wiki repository: shell error'
)
end
it 'resets last_wiki_successful_sync_at' do
expect(registry.last_wiki_successful_sync_at).to be_nil
end
it 'calls repository cleanup' do
expect(repository).to receive(:clean_stale_repository_files)
it 'sets last_wiki_sync_failure' do
expect(registry.last_wiki_sync_failure).to eq('Error syncing wiki repository: shell error')
subject.execute
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