2021-04-29 21:17:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Ci
|
|
|
|
class AfterRequeueJobService < ::BaseService
|
|
|
|
def execute(processable)
|
|
|
|
process_subsequent_jobs(processable)
|
2021-06-08 01:23:25 +05:30
|
|
|
reset_source_bridge(processable)
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def process_subsequent_jobs(processable)
|
2021-09-30 23:02:18 +05:30
|
|
|
if Feature.enabled?(:ci_same_stage_job_needs, processable.project, default_enabled: :yaml)
|
|
|
|
(stage_dependent_jobs(processable) | needs_dependent_jobs(processable))
|
|
|
|
.each do |processable|
|
|
|
|
process(processable)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
skipped_jobs(processable).after_stage(processable.stage_idx)
|
|
|
|
.find_each do |job|
|
|
|
|
process(job)
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
def reset_source_bridge(processable)
|
|
|
|
processable.pipeline.reset_source_bridge!(current_user)
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def process(processable)
|
|
|
|
Gitlab::OptimisticLocking.retry_lock(processable, name: 'ci_requeue_job') do |processable|
|
|
|
|
processable.process(current_user)
|
|
|
|
end
|
|
|
|
end
|
2021-09-30 23:02:18 +05:30
|
|
|
|
|
|
|
def skipped_jobs(processable)
|
|
|
|
processable.pipeline.processables.skipped
|
|
|
|
end
|
|
|
|
|
|
|
|
def stage_dependent_jobs(processable)
|
|
|
|
skipped_jobs(processable).scheduling_type_stage.after_stage(processable.stage_idx)
|
|
|
|
end
|
|
|
|
|
|
|
|
def needs_dependent_jobs(processable)
|
|
|
|
skipped_jobs(processable).scheduling_type_dag.with_needs([processable.name])
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
end
|