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