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>2020-12-17 14:59:07 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 14:59:07 +0300
commit8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch)
tree544930fb309b30317ae9797a9683768705d664c4 /app/workers/concerns/gitlab
parent4b1de649d0168371549608993deac953eb692019 (diff)
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'app/workers/concerns/gitlab')
-rw-r--r--app/workers/concerns/gitlab/github_import/object_importer.rb39
-rw-r--r--app/workers/concerns/gitlab/github_import/rescheduling_methods.rb2
-rw-r--r--app/workers/concerns/gitlab/github_import/stage_methods.rb39
3 files changed, 78 insertions, 2 deletions
diff --git a/app/workers/concerns/gitlab/github_import/object_importer.rb b/app/workers/concerns/gitlab/github_import/object_importer.rb
index 63c1ba8e699..575cd4862b0 100644
--- a/app/workers/concerns/gitlab/github_import/object_importer.rb
+++ b/app/workers/concerns/gitlab/github_import/object_importer.rb
@@ -15,17 +15,25 @@ 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.
# client - An instance of `Gitlab::GithubImport::Client`
# hash - A Hash containing the details of the object to import.
def import(project, client, hash)
- object = representation_class.from_json_hash(hash)
+ info(project.id, message: 'starting importer')
+ object = representation_class.from_json_hash(hash)
importer_class.new(object, project, client).execute
counter.increment
+ info(project.id, message: 'importer finished')
+ rescue => e
+ error(project.id, e)
end
def counter
@@ -52,6 +60,35 @@ module Gitlab
def counter_description
raise NotImplementedError
end
+
+ private
+
+ def info(project_id, extra = {})
+ logger.info(log_attributes(project_id, extra))
+ end
+
+ def error(project_id, exception)
+ logger.error(
+ log_attributes(
+ project_id,
+ message: 'importer failed',
+ 'error.message': exception.message
+ )
+ )
+
+ Gitlab::ErrorTracking.track_and_raise_exception(
+ exception,
+ log_attributes(project_id)
+ )
+ end
+
+ def log_attributes(project_id, extra = {})
+ extra.merge(
+ import_source: :github,
+ project_id: project_id,
+ importer: importer_class.name
+ )
+ end
end
end
end
diff --git a/app/workers/concerns/gitlab/github_import/rescheduling_methods.rb b/app/workers/concerns/gitlab/github_import/rescheduling_methods.rb
index 1c6413674a0..eb1af0869bd 100644
--- a/app/workers/concerns/gitlab/github_import/rescheduling_methods.rb
+++ b/app/workers/concerns/gitlab/github_import/rescheduling_methods.rb
@@ -6,7 +6,7 @@ module Gitlab
# importing GitHub projects.
module ReschedulingMethods
# project_id - The ID of the GitLab project to import the note into.
- # hash - A Hash containing the details of the GitHub object to imoprt.
+ # hash - A Hash containing the details of the GitHub object to import.
# notify_key - The Redis key to notify upon completion, if any.
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, hash, notify_key = nil)
diff --git a/app/workers/concerns/gitlab/github_import/stage_methods.rb b/app/workers/concerns/gitlab/github_import/stage_methods.rb
index e2dee315cde..e5985fb94da 100644
--- a/app/workers/concerns/gitlab/github_import/stage_methods.rb
+++ b/app/workers/concerns/gitlab/github_import/stage_methods.rb
@@ -5,11 +5,17 @@ module Gitlab
module StageMethods
# project_id - The ID of the GitLab project to import the data into.
def perform(project_id)
+ info(project_id, message: 'starting stage')
+
return unless (project = find_project(project_id))
client = GithubImport.new_client_for(project)
try_import(client, project)
+
+ info(project_id, message: 'stage finished')
+ rescue => e
+ error(project_id, e)
end
# client - An instance of Gitlab::GithubImport::Client.
@@ -27,6 +33,39 @@ module Gitlab
Project.joins_import_state.where(import_state: { status: :started }).find_by(id: id)
end
# rubocop: enable CodeReuse/ActiveRecord
+
+ private
+
+ def info(project_id, extra = {})
+ logger.info(log_attributes(project_id, extra))
+ end
+
+ def error(project_id, exception)
+ logger.error(
+ log_attributes(
+ project_id,
+ message: 'stage failed',
+ 'error.message': exception.message
+ )
+ )
+
+ Gitlab::ErrorTracking.track_and_raise_exception(
+ exception,
+ log_attributes(project_id)
+ )
+ 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