Commit 5a074cc5 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'sh-consolidate-git-base-errors' into 'master'

Make all Gitlab::Git exceptions inherit from Gitlab::Git::BaseError

See merge request gitlab-org/gitlab!42132
parents 3630fe77 3da999e6
......@@ -10,18 +10,18 @@ module Geo
start_registry_sync!
fetch_repository
mark_sync_as_successful
rescue Gitlab::Git::Repository::NoRepository => e
log_info('Marking the design repository for a forced re-download')
fail_registry_sync!('Invalid design repository', e, force_to_redownload: true)
rescue Gitlab::Shell::Error, Gitlab::Git::BaseError => e
# In some cases repository does not exist, the only way to know about this is to parse the error text.
# If it does not exist we should consider it as successfully downloaded.
if e.message.include? Gitlab::GitAccess::ERROR_MESSAGES[:no_repo]
if e.message.include? Gitlab::GitAccess::ERROR_MESSAGES[:no_repo] # rubocop:disable Cop/LineBreakAroundConditionalBlock
log_info('Design repository is not found, marking it as successfully synced')
mark_sync_as_successful(missing_on_primary: true)
else
fail_registry_sync!('Error syncing design repository', e)
end
rescue Gitlab::Git::Repository::NoRepository => e
log_info('Marking the design repository for a forced re-download')
fail_registry_sync!('Invalid design repository', e, force_to_redownload: true)
ensure
expire_repository_caches
end
......
......@@ -11,9 +11,15 @@ module Geo
fetch_repository
update_root_ref
mark_sync_as_successful
rescue Gitlab::Git::Repository::NoRepository => e
log_info('Setting force_to_redownload flag')
fail_registry_sync!('Invalid repository', e, force_to_redownload_repository: true)
log_info('Expiring caches')
project.repository.after_create
rescue Gitlab::Shell::Error, Gitlab::Git::BaseError => e
# In some cases repository does not exist, the only way to know about this is to parse the error text.
if e.message.include? Gitlab::GitAccess::ERROR_MESSAGES[:no_repo]
if e.message.include? Gitlab::GitAccess::ERROR_MESSAGES[:no_repo] # rubocop:disable Cop/LineBreakAroundConditionalBlock
if repository_presumably_exists_on_primary?
log_info('Repository is not found, but it seems to exist on the primary')
fail_registry_sync!('Repository is not found', e)
......@@ -24,12 +30,6 @@ module Geo
else
fail_registry_sync!('Error syncing repository', e)
end
rescue Gitlab::Git::Repository::NoRepository => e
log_info('Setting force_to_redownload flag')
fail_registry_sync!('Invalid repository', e, force_to_redownload_repository: true)
log_info('Expiring caches')
project.repository.after_create
ensure
expire_repository_caches
execute_housekeeping
......
......@@ -10,10 +10,13 @@ module Geo
start_registry_sync!
fetch_repository
mark_sync_as_successful
rescue Gitlab::Git::Repository::NoRepository => e
log_info('Setting force_to_redownload flag')
fail_registry_sync!('Invalid wiki', e, force_to_redownload_wiki: true)
rescue Gitlab::Shell::Error, Gitlab::Git::BaseError, Wiki::CouldNotCreateWikiError => e
# In some cases repository does not exist, the only way to know about this is to parse the error text.
# If it does not exist we should consider it as successfully downloaded.
if e.message.include? Gitlab::GitAccess::ERROR_MESSAGES[:no_repo]
if e.message.include? Gitlab::GitAccess::ERROR_MESSAGES[:no_repo] # rubocop:disable Cop/LineBreakAroundConditionalBlock
if repository_presumably_exists_on_primary?
log_info('Wiki is not found, but it seems to exist on the primary')
fail_registry_sync!('Wiki is not found', e)
......@@ -24,9 +27,6 @@ module Geo
else
fail_registry_sync!('Error syncing wiki repository', e)
end
rescue Gitlab::Git::Repository::NoRepository => e
log_info('Setting force_to_redownload flag')
fail_registry_sync!('Invalid wiki', e, force_to_redownload_wiki: true)
ensure
expire_repository_caches
end
......
......@@ -19,15 +19,15 @@ module Gitlab
GITLAB_PROJECTS_TIMEOUT = Gitlab.config.gitlab_shell.git_timeout
EMPTY_REPOSITORY_CHECKSUM = '0000000000000000000000000000000000000000'
NoRepository = Class.new(StandardError)
InvalidRepository = Class.new(StandardError)
InvalidBlobName = Class.new(StandardError)
InvalidRef = Class.new(StandardError)
GitError = Class.new(StandardError)
DeleteBranchError = Class.new(StandardError)
TagExistsError = Class.new(StandardError)
ChecksumError = Class.new(StandardError)
class CreateTreeError < StandardError
NoRepository = Class.new(::Gitlab::Git::BaseError)
InvalidRepository = Class.new(::Gitlab::Git::BaseError)
InvalidBlobName = Class.new(::Gitlab::Git::BaseError)
InvalidRef = Class.new(::Gitlab::Git::BaseError)
GitError = Class.new(::Gitlab::Git::BaseError)
DeleteBranchError = Class.new(::Gitlab::Git::BaseError)
TagExistsError = Class.new(::Gitlab::Git::BaseError)
ChecksumError = Class.new(::Gitlab::Git::BaseError)
class CreateTreeError < ::Gitlab::Git::BaseError
attr_reader :error_code
def initialize(error_code)
......
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