From 574bb25239aef92d307c40a27d7867b0796ae9c2 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Thu, 2 May 2019 12:12:58 +0300 Subject: Address review comments: better names for variables renamed `finish_sync!` and `start_registry!` methods --- ee/app/models/geo/project_registry.rb | 6 +++--- ee/app/services/geo/base_sync_service.rb | 4 ++-- ee/app/services/geo/repository_sync_service.rb | 8 ++++---- ee/app/services/geo/wiki_sync_service.rb | 8 ++++---- ee/spec/services/geo/repository_sync_service_spec.rb | 2 +- ee/spec/services/geo/wiki_sync_service_spec.rb | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ee/app/models/geo/project_registry.rb b/ee/app/models/geo/project_registry.rb index 0cb52b726a6..1458509957d 100644 --- a/ee/app/models/geo/project_registry.rb +++ b/ee/app/models/geo/project_registry.rb @@ -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 diff --git a/ee/app/services/geo/base_sync_service.rb b/ee/app/services/geo/base_sync_service.rb index 5ef1074d972..6d4800129c7 100644 --- a/ee/app/services/geo/base_sync_service.rb +++ b/ee/app/services/geo/base_sync_service.rb @@ -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) diff --git a/ee/app/services/geo/repository_sync_service.rb b/ee/app/services/geo/repository_sync_service.rb index 2add158654b..f21120c47e3 100644 --- a/ee/app/services/geo/repository_sync_service.rb +++ b/ee/app/services/geo/repository_sync_service.rb @@ -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 diff --git a/ee/app/services/geo/wiki_sync_service.rb b/ee/app/services/geo/wiki_sync_service.rb index 2be697eaf91..9a1a648f566 100644 --- a/ee/app/services/geo/wiki_sync_service.rb +++ b/ee/app/services/geo/wiki_sync_service.rb @@ -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 diff --git a/ee/spec/services/geo/repository_sync_service_spec.rb b/ee/spec/services/geo/repository_sync_service_spec.rb index d8a81b8cbd2..0c588576d7f 100644 --- a/ee/spec/services/geo/repository_sync_service_spec.rb +++ b/ee/spec/services/geo/repository_sync_service_spec.rb @@ -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 diff --git a/ee/spec/services/geo/wiki_sync_service_spec.rb b/ee/spec/services/geo/wiki_sync_service_spec.rb index 84a0543d34f..9bbce6eb771 100644 --- a/ee/spec/services/geo/wiki_sync_service_spec.rb +++ b/ee/spec/services/geo/wiki_sync_service_spec.rb @@ -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 -- cgit v1.2.1