Class: Gitlab::Ci::Pipeline::Chain::CancelPendingPipelines

Inherits:
Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/gitlab/ci/pipeline/chain/cancel_pending_pipelines.rb

Constant Summary collapse

BATCH_SIZE =
25

Instance Attribute Summary

Attributes inherited from Base

#command, #config, #pipeline

Instance Method Summary collapse

Methods included from Helpers

#error, #warning

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Gitlab::Ci::Pipeline::Chain::Base

Instance Method Details

#break?Boolean

rubocop: enable CodeReuse/ActiveRecord

Returns:

  • (Boolean)

24
25
26
# File 'lib/gitlab/ci/pipeline/chain/cancel_pending_pipelines.rb', line 24

def break?
  false
end

#perform!Object

rubocop: disable CodeReuse/ActiveRecord


13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/ci/pipeline/chain/cancel_pending_pipelines.rb', line 13

def perform!
  return unless project.auto_cancel_pending_pipelines?

  Gitlab::OptimisticLocking.retry_lock(auto_cancelable_pipelines, name: 'cancel_pending_pipelines') do |cancelables|
    cancelables.select(:id).each_batch(of: BATCH_SIZE) do |cancelables_batch|
      auto_cancel_interruptible_pipelines(cancelables_batch.ids)
    end
  end
end