diff options
Diffstat (limited to 'lib/gitlab/github_import/parallel_scheduling.rb')
-rw-r--r-- | lib/gitlab/github_import/parallel_scheduling.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/gitlab/github_import/parallel_scheduling.rb b/lib/gitlab/github_import/parallel_scheduling.rb index cabc615ea11..51859010ec3 100644 --- a/lib/gitlab/github_import/parallel_scheduling.rb +++ b/lib/gitlab/github_import/parallel_scheduling.rb @@ -26,6 +26,8 @@ module Gitlab end def execute + info(project.id, message: "starting importer") + retval = if parallel? parallel_import @@ -43,8 +45,13 @@ module Gitlab # completed those jobs will just cycle through any remaining pages while # not scheduling anything. Gitlab::Cache::Import::Caching.expire(already_imported_cache_key, 15.minutes.to_i) + info(project.id, message: "importer finished") retval + rescue => e + error(project.id, e) + + raise e end # Imports all the objects in sequence in the current thread. @@ -157,6 +164,40 @@ module Gitlab def collection_options {} 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_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, + parallel: parallel? + ) + end + + def logger + @logger ||= Gitlab::Import::Logger.build + end end end end |