Commit 7dae62cb authored by James Lopez's avatar James Lopez

refactor failure logging after merge with master

parent 79460248
...@@ -150,12 +150,6 @@ module Geo ...@@ -150,12 +150,6 @@ module Geo
registry.update!(attrs) registry.update!(attrs)
end end
def fail_registry(message, error)
log_error(message, error)
registry.update!(last_repository_sync_failure: "#{message}: #{error.message}")
end
def type def type
self.class.type self.class.type
end end
......
...@@ -20,22 +20,25 @@ module Geo ...@@ -20,22 +20,25 @@ module Geo
else else
project.ensure_repository project.ensure_repository
fetch_geo_mirror(project.repository) fetch_geo_mirror(project.repository)
end update_registry(finished_at: DateTime.now) end
log_info('Finished repository sync', update_registry(finished_at: DateTime.now)
update_delay_s: update_delay_in_seconds, log_info('Finished repository sync',
download_time_s: download_time_in_seconds) update_delay_s: update_delay_in_seconds,
rescue Gitlab::Shell::Error, download_time_s: download_time_in_seconds)
Gitlab::Git::RepositoryMirroring::RemoteError, rescue Gitlab::Shell::Error,
Geo::EmptyCloneUrlPrefixError => e Gitlab::Git::RepositoryMirroring::RemoteError,
fail_registry('Error syncing repository', e) Geo::EmptyCloneUrlPrefixError => e
registry.increment!(:repository_retry_count)rescue Gitlab::Git::Repository::NoRepository => e fail_registry('Error syncing repository', e)
fail_registry('Invalid repository', e) rescue Gitlab::Git::Repository::NoRepository => e
fail_registry('Invalid repository', e)
log_info('Setting force_to_redownload flag') log_info('Setting force_to_redownload flag')
registry.update(force_to_redownload_repository: true, registry.update(force_to_redownload_repository: true)
repository_retry_count: retry_count + 1) log_info('Expiring caches')
project.repository.after_create log_info('Expiring caches')
ensure project.repository.after_create
ensure
clean_up_temporary_repository if redownload clean_up_temporary_repository if redownload
end end
...@@ -52,6 +55,13 @@ module Geo ...@@ -52,6 +55,13 @@ module Geo
project.repository project.repository
end end
def fail_registry(message, error)
log_error(message, error)
registry.update!(last_repository_sync_failure: "#{message}: #{error.message}",
repository_retry_count: retry_count + 1)
end
def retry_count def retry_count
registry.public_send("#{type}_retry_count") || -1 # rubocop:disable GitlabSecurity/PublicSend registry.public_send("#{type}_retry_count") || -1 # rubocop:disable GitlabSecurity/PublicSend
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