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