diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /lib/bulk_imports/groups/pipelines/entity_finisher.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'lib/bulk_imports/groups/pipelines/entity_finisher.rb')
-rw-r--r-- | lib/bulk_imports/groups/pipelines/entity_finisher.rb | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/bulk_imports/groups/pipelines/entity_finisher.rb b/lib/bulk_imports/groups/pipelines/entity_finisher.rb index 1d237bc0f7f..1a709179bf9 100644 --- a/lib/bulk_imports/groups/pipelines/entity_finisher.rb +++ b/lib/bulk_imports/groups/pipelines/entity_finisher.rb @@ -4,31 +4,45 @@ module BulkImports module Groups module Pipelines class EntityFinisher + def self.ndjson_pipeline? + false + end + def initialize(context) @context = context + @entity = @context.entity + @trackers = @entity.trackers end def run - return if context.entity.finished? + return if entity.finished? || entity.failed? - context.entity.finish! + if all_other_trackers_failed? + entity.fail_op! + else + entity.finish! + end logger.info( bulk_import_id: context.bulk_import.id, bulk_import_entity_id: context.entity.id, bulk_import_entity_type: context.entity.source_type, pipeline_class: self.class.name, - message: 'Entity finished' + message: "Entity #{entity.status_name}" ) end private - attr_reader :context + attr_reader :context, :entity, :trackers def logger @logger ||= Gitlab::Import::Logger.build end + + def all_other_trackers_failed? + trackers.where.not(relation: self.class.name).all? { |tracker| tracker.failed? } # rubocop: disable CodeReuse/ActiveRecord + end end end end |