Class: Ci::PipelineCreation::CancelRedundantPipelinesService
- Inherits:
-
Object
- Object
- Ci::PipelineCreation::CancelRedundantPipelinesService
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/ci/pipeline_creation/cancel_redundant_pipelines_service.rb
Constant Summary collapse
- BATCH_SIZE =
25
- PAGE_SIZE =
500
Instance Method Summary collapse
-
#execute ⇒ Object
rubocop: disable CodeReuse/ActiveRecord.
-
#initialize(pipeline) ⇒ CancelRedundantPipelinesService
constructor
A new instance of CancelRedundantPipelinesService.
Constructor Details
#initialize(pipeline) ⇒ CancelRedundantPipelinesService
Returns a new instance of CancelRedundantPipelinesService.
11 12 13 14 |
# File 'app/services/ci/pipeline_creation/cancel_redundant_pipelines_service.rb', line 11 def initialize(pipeline) @pipeline = pipeline @project = @pipeline.project end |
Instance Method Details
#execute ⇒ Object
rubocop: disable CodeReuse/ActiveRecord
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/ci/pipeline_creation/cancel_redundant_pipelines_service.rb', line 17 def execute return if service_disabled? return if pipeline.parent_pipeline? # skip if child pipeline return unless project.auto_cancel_pending_pipelines? paginator.each do |ids| pipelines = parent_and_child_pipelines(ids) Gitlab::OptimisticLocking.retry_lock(pipelines, name: 'cancel_pending_pipelines') do |cancelables| auto_cancel_interruptible_pipelines(cancelables.ids) end end end |