Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 12:08:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 12:08:42 +0300
commitb76ae638462ab0f673e5915986070518dd3f9ad3 (patch)
treebdab0533383b52873be0ec0eb4d3c66598ff8b91 /app/workers/concerns/gitlab
parent434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff)
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'app/workers/concerns/gitlab')
-rw-r--r--app/workers/concerns/gitlab/github_import/object_importer.rb41
-rw-r--r--app/workers/concerns/gitlab/github_import/queue.rb11
-rw-r--r--app/workers/concerns/gitlab/github_import/stage_methods.rb35
3 files changed, 35 insertions, 52 deletions
diff --git a/app/workers/concerns/gitlab/github_import/object_importer.rb b/app/workers/concerns/gitlab/github_import/object_importer.rb
index 1eff53cea01..a377b7a2000 100644
--- a/app/workers/concerns/gitlab/github_import/object_importer.rb
+++ b/app/workers/concerns/gitlab/github_import/object_importer.rb
@@ -17,10 +17,6 @@ module Gitlab
feature_category :importers
worker_has_external_dependencies!
-
- def logger
- @logger ||= Gitlab::Import::Logger.build
- end
end
# project - An instance of `Project` to import the data into.
@@ -39,8 +35,24 @@ module Gitlab
Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :imported)
info(project.id, message: 'importer finished')
+ rescue KeyError => e
+ # This exception will be more useful in development when a new
+ # Representation is created but the developer forgot to add a
+ # `:github_id` field.
+ Gitlab::Import::ImportFailureService.track(
+ project_id: project.id,
+ error_source: importer_class.name,
+ exception: e,
+ fail_import: true
+ )
+
+ raise(e)
rescue StandardError => e
- error(project.id, e, hash)
+ Gitlab::Import::ImportFailureService.track(
+ project_id: project.id,
+ error_source: importer_class.name,
+ exception: e
+ )
end
def object_type
@@ -63,28 +75,11 @@ module Gitlab
attr_accessor :github_id
def info(project_id, extra = {})
- logger.info(log_attributes(project_id, extra))
- end
-
- def error(project_id, exception, data = {})
- logger.error(
- log_attributes(
- project_id,
- message: 'importer failed',
- 'error.message': exception.message,
- 'github.data': data
- )
- )
-
- Gitlab::ErrorTracking.track_and_raise_exception(
- exception,
- log_attributes(project_id)
- )
+ Logger.info(log_attributes(project_id, extra))
end
def log_attributes(project_id, extra = {})
extra.merge(
- import_source: :github,
project_id: project_id,
importer: importer_class.name,
github_id: github_id
diff --git a/app/workers/concerns/gitlab/github_import/queue.rb b/app/workers/concerns/gitlab/github_import/queue.rb
index 05eb7fbc2cb..e7156ac12f8 100644
--- a/app/workers/concerns/gitlab/github_import/queue.rb
+++ b/app/workers/concerns/gitlab/github_import/queue.rb
@@ -17,13 +17,10 @@ module Gitlab
sidekiq_options dead: false, retry: 5
sidekiq_retries_exhausted do |msg, e|
- Gitlab::Import::Logger.error(
- event: :github_importer_exhausted,
- message: msg['error_message'],
- class: msg['class'],
- args: msg['args'],
- exception_message: e.message,
- exception_backtrace: e.backtrace
+ Gitlab::Import::ImportFailureService.track(
+ project_id: msg['args'][0],
+ exception: e,
+ fail_import: true
)
end
end
diff --git a/app/workers/concerns/gitlab/github_import/stage_methods.rb b/app/workers/concerns/gitlab/github_import/stage_methods.rb
index 916b273a28f..d7b4578af63 100644
--- a/app/workers/concerns/gitlab/github_import/stage_methods.rb
+++ b/app/workers/concerns/gitlab/github_import/stage_methods.rb
@@ -15,7 +15,14 @@ module Gitlab
info(project_id, message: 'stage finished')
rescue StandardError => e
- error(project_id, e)
+ Gitlab::Import::ImportFailureService.track(
+ project_id: project_id,
+ exception: e,
+ error_source: self.class.name,
+ fail_import: abort_on_failure
+ )
+
+ raise(e)
end
# client - An instance of Gitlab::GithubImport::Client.
@@ -34,38 +41,22 @@ module Gitlab
end
# rubocop: enable CodeReuse/ActiveRecord
- private
-
- def info(project_id, extra = {})
- logger.info(log_attributes(project_id, extra))
+ def abort_on_failure
+ false
end
- def error(project_id, exception)
- logger.error(
- log_attributes(
- project_id,
- message: 'stage failed',
- 'error.message': exception.message
- )
- )
+ private
- Gitlab::ErrorTracking.track_and_raise_exception(
- exception,
- log_attributes(project_id)
- )
+ def info(project_id, extra = {})
+ Gitlab::GithubImport::Logger.info(log_attributes(project_id, extra))
end
def log_attributes(project_id, extra = {})
extra.merge(
- import_source: :github,
project_id: project_id,
import_stage: self.class.name
)
end
-
- def logger
- @logger ||= Gitlab::Import::Logger.build
- end
end
end
end