debian-mirror-gitlab/app/services/ci/after_requeue_job_service.rb

49 lines
1 KiB
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
module Ci
class AfterRequeueJobService < ::BaseService
def execute(processable)
2022-01-26 12:08:38 +05:30
@processable = processable
process_subsequent_jobs
reset_source_bridge
2021-04-29 21:17:54 +05:30
end
private
2022-01-26 12:08:38 +05:30
def process_subsequent_jobs
dependent_jobs.each do |job|
process(job)
2021-04-29 21:17:54 +05:30
end
end
2022-01-26 12:08:38 +05:30
def reset_source_bridge
@processable.pipeline.reset_source_bridge!(current_user)
end
def dependent_jobs
2022-04-04 11:22:00 +05:30
stage_dependent_jobs
.or(needs_dependent_jobs.except(:preload))
.ordered_by_stage
2021-04-29 21:17:54 +05:30
end
2022-01-26 12:08:38 +05:30
def process(job)
Gitlab::OptimisticLocking.retry_lock(job, name: 'ci_requeue_job') do |job|
job.process(current_user)
2021-04-29 21:17:54 +05:30
end
end
2021-09-30 23:02:18 +05:30
2022-01-26 12:08:38 +05:30
def stage_dependent_jobs
skipped_jobs.after_stage(@processable.stage_idx)
2021-09-30 23:02:18 +05:30
end
2022-01-26 12:08:38 +05:30
def needs_dependent_jobs
skipped_jobs.scheduling_type_dag.with_needs([@processable.name])
2021-09-30 23:02:18 +05:30
end
2022-01-26 12:08:38 +05:30
def skipped_jobs
@skipped_jobs ||= @processable.pipeline.processables.skipped
2021-09-30 23:02:18 +05:30
end
2021-04-29 21:17:54 +05:30
end
end