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 ...@@ -10,18 +10,18 @@ module Geo
start_registry_sync! start_registry_sync!
fetch_repository fetch_repository
mark_sync_as_successful 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 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. # 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 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') log_info('Design 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)
else else
fail_registry_sync!('Error syncing design repository', e) fail_registry_sync!('Error syncing design repository', e)
end 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 ensure
expire_repository_caches expire_repository_caches
end end
......
...@@ -11,9 +11,15 @@ module Geo ...@@ -11,9 +11,15 @@ module Geo
fetch_repository fetch_repository
update_root_ref update_root_ref
mark_sync_as_successful 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 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. # 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? 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_sync!('Repository is not found', e) fail_registry_sync!('Repository is not found', e)
...@@ -24,12 +30,6 @@ module Geo ...@@ -24,12 +30,6 @@ module Geo
else else
fail_registry_sync!('Error syncing repository', e) fail_registry_sync!('Error syncing repository', e)
end 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 ensure
expire_repository_caches expire_repository_caches
execute_housekeeping execute_housekeeping
......
...@@ -10,10 +10,13 @@ module Geo ...@@ -10,10 +10,13 @@ module Geo
start_registry_sync! start_registry_sync!
fetch_repository fetch_repository
mark_sync_as_successful 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 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. # 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 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? 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_sync!('Wiki is not found', e) fail_registry_sync!('Wiki is not found', e)
...@@ -24,9 +27,6 @@ module Geo ...@@ -24,9 +27,6 @@ module Geo
else else
fail_registry_sync!('Error syncing wiki repository', e) fail_registry_sync!('Error syncing wiki repository', e)
end 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 ensure
expire_repository_caches expire_repository_caches
end end
......
...@@ -19,15 +19,15 @@ module Gitlab ...@@ -19,15 +19,15 @@ module Gitlab
GITLAB_PROJECTS_TIMEOUT = Gitlab.config.gitlab_shell.git_timeout GITLAB_PROJECTS_TIMEOUT = Gitlab.config.gitlab_shell.git_timeout
EMPTY_REPOSITORY_CHECKSUM = '0000000000000000000000000000000000000000' EMPTY_REPOSITORY_CHECKSUM = '0000000000000000000000000000000000000000'
NoRepository = Class.new(StandardError) NoRepository = Class.new(::Gitlab::Git::BaseError)
InvalidRepository = Class.new(StandardError) InvalidRepository = Class.new(::Gitlab::Git::BaseError)
InvalidBlobName = Class.new(StandardError) InvalidBlobName = Class.new(::Gitlab::Git::BaseError)
InvalidRef = Class.new(StandardError) InvalidRef = Class.new(::Gitlab::Git::BaseError)
GitError = Class.new(StandardError) GitError = Class.new(::Gitlab::Git::BaseError)
DeleteBranchError = Class.new(StandardError) DeleteBranchError = Class.new(::Gitlab::Git::BaseError)
TagExistsError = Class.new(StandardError) TagExistsError = Class.new(::Gitlab::Git::BaseError)
ChecksumError = Class.new(StandardError) ChecksumError = Class.new(::Gitlab::Git::BaseError)
class CreateTreeError < StandardError class CreateTreeError < ::Gitlab::Git::BaseError
attr_reader :error_code attr_reader :error_code
def initialize(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