Commit 574bb252 authored by Valery Sizov's avatar Valery Sizov

Address review comments: better names for variables

renamed `finish_sync!` and `start_registry!` methods
parent 34912b6f
......@@ -254,12 +254,12 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
def fail_sync!(type, message, error, attrs = {})
ensure_valid_type!(type)
new_count = retry_count(type) + 1
new_retry_count = retry_count(type) + 1
attrs["resync_#{type}"] = true
attrs["last_#{type}_sync_failure"] = "#{message}: #{error.message}"
attrs["#{type}_retry_count"] = new_count
attrs["#{type}_retry_at"] = next_retry_time(new_count)
attrs["#{type}_retry_count"] = new_retry_count
attrs["#{type}_retry_at"] = next_retry_time(new_retry_count)
update!(attrs)
end
......
......@@ -157,12 +157,12 @@ module Geo
)
end
def start_registry!
def start_registry_sync!
log_info("Marking #{type} sync as started")
registry.start_sync!(type)
end
def fail_registry!(message, error, attrs = {})
def fail_registry_sync!(message, error, attrs = {})
log_error(message, error)
registry.fail_sync!(type, message, error, attrs)
......
......@@ -7,7 +7,7 @@ module Geo
private
def sync_repository
start_registry!
start_registry_sync!
fetch_repository
update_root_ref
mark_sync_as_successful
......@@ -16,17 +16,17 @@ module Geo
if e.message.include? Gitlab::GitAccess::ERROR_MESSAGES[:no_repo]
if repository_presumably_exists_on_primary?
log_info('Repository is not found, but it seems to exist on the primary')
fail_registry!('Repository is not found', e)
fail_registry_sync!('Repository is not found', e)
else
log_info('Repository is not found, marking it as successfully synced')
mark_sync_as_successful(missing_on_primary: true)
end
else
fail_registry!('Error syncing repository', e)
fail_registry_sync!('Error syncing repository', e)
end
rescue Gitlab::Git::Repository::NoRepository => e
log_info('Setting force_to_redownload flag')
fail_registry!('Invalid repository', e, force_to_redownload_repository: true)
fail_registry_sync!('Invalid repository', e, force_to_redownload_repository: true)
log_info('Expiring caches')
project.repository.after_create
......
......@@ -7,7 +7,7 @@ module Geo
private
def sync_repository
start_registry!
start_registry_sync!
fetch_repository
mark_sync_as_successful
rescue Gitlab::Shell::Error, Gitlab::Git::BaseError, ProjectWiki::CouldNotCreateWikiError => e
......@@ -16,17 +16,17 @@ module Geo
if e.message.include? Gitlab::GitAccess::ERROR_MESSAGES[:no_repo]
if repository_presumably_exists_on_primary?
log_info('Wiki is not found, but it seems to exist on the primary')
fail_registry!('Wiki is not found', e)
fail_registry_sync!('Wiki is not found', e)
else
log_info('Wiki is not found, marking it as successfully synced')
mark_sync_as_successful(missing_on_primary: true)
end
else
fail_registry!('Error syncing wiki repository', e)
fail_registry_sync!('Error syncing wiki repository', e)
end
rescue Gitlab::Git::Repository::NoRepository => e
log_info('Setting force_to_redownload flag')
fail_registry!('Invalid wiki', e, force_to_redownload_wiki: true)
fail_registry_sync!('Invalid wiki', e, force_to_redownload_wiki: true)
ensure
expire_repository_caches
end
......
......@@ -424,7 +424,7 @@ describe Geo::RepositorySyncService do
)
expect(project.repository).to receive(:expire_exists_cache).twice.and_call_original
expect(subject).not_to receive(:fail_registry!)
expect(subject).not_to receive(:fail_registry_sync!)
subject.execute
end
......
......@@ -230,7 +230,7 @@ RSpec.describe Geo::WikiSyncService do
)
expect(project.wiki.repository).to receive(:expire_exists_cache).twice.and_call_original
expect(subject).not_to receive(:fail_registry!)
expect(subject).not_to receive(:fail_registry_sync!)
subject.execute
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