Commit aa2a7ce3 authored by Furkan Ayhan's avatar Furkan Ayhan

Fix non-retrying bridges after retried builds in CI pipelines

After a build is retried, we need to mark as processable not only
builds but also all processables.
This commit also moves mark_as_processable_after_stage method into
Ci::RetryBuildService
parent d441a318
......@@ -539,12 +539,6 @@ module Ci
end
# rubocop: enable CodeReuse/ServiceClass
def mark_as_processable_after_stage(stage_idx)
builds.skipped.after_stage(stage_idx).find_each do |build|
Gitlab::OptimisticLocking.retry_lock(build, &:process)
end
end
def lazy_ref_commit
return unless ::Gitlab::Ci::Features.pipeline_latest?
......
......@@ -12,7 +12,7 @@ module Ci
build.ensure_scheduling_type!
reprocess!(build).tap do |new_build|
build.pipeline.mark_as_processable_after_stage(build.stage_idx)
mark_subsequent_stages_as_processable(build)
Gitlab::OptimisticLocking.retry_lock(new_build, &:enqueue)
......@@ -60,5 +60,11 @@ module Ci
end
build
end
def mark_subsequent_stages_as_processable(build)
build.pipeline.processables.skipped.after_stage(build.stage_idx).find_each do |processable|
Gitlab::OptimisticLocking.retry_lock(processable, &:process)
end
end
end
end
---
title: Fix non-retrying bridges after retried builds in CI pipelines
merge_request: 39989
author:
type: fixed
......@@ -53,5 +53,10 @@ FactoryBot.define do
finished
status { 'failed' }
end
trait :skipped do
started
status { 'skipped' }
end
end
end
......@@ -181,17 +181,24 @@ RSpec.describe Ci::RetryBuildService do
service.execute(build)
end
context 'when there are subsequent builds that are skipped' do
context 'when there are subsequent processables that are skipped' do
let!(:subsequent_build) do
create(:ci_build, :skipped, stage_idx: 2,
pipeline: pipeline,
stage: 'deploy')
end
it 'resumes pipeline processing in a subsequent stage' do
let!(:subsequent_bridge) do
create(:ci_bridge, :skipped, stage_idx: 2,
pipeline: pipeline,
stage: 'deploy')
end
it 'resumes pipeline processing in the subsequent stage' do
service.execute(build)
expect(subsequent_build.reload).to be_created
expect(subsequent_bridge.reload).to be_created
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment