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 ...@@ -539,12 +539,6 @@ module Ci
end end
# rubocop: enable CodeReuse/ServiceClass # 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 def lazy_ref_commit
return unless ::Gitlab::Ci::Features.pipeline_latest? return unless ::Gitlab::Ci::Features.pipeline_latest?
......
...@@ -12,7 +12,7 @@ module Ci ...@@ -12,7 +12,7 @@ module Ci
build.ensure_scheduling_type! build.ensure_scheduling_type!
reprocess!(build).tap do |new_build| 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) Gitlab::OptimisticLocking.retry_lock(new_build, &:enqueue)
...@@ -60,5 +60,11 @@ module Ci ...@@ -60,5 +60,11 @@ module Ci
end end
build build
end 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
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 ...@@ -53,5 +53,10 @@ FactoryBot.define do
finished finished
status { 'failed' } status { 'failed' }
end end
trait :skipped do
started
status { 'skipped' }
end
end end
end end
...@@ -181,17 +181,24 @@ RSpec.describe Ci::RetryBuildService do ...@@ -181,17 +181,24 @@ RSpec.describe Ci::RetryBuildService do
service.execute(build) service.execute(build)
end 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 let!(:subsequent_build) do
create(:ci_build, :skipped, stage_idx: 2, create(:ci_build, :skipped, stage_idx: 2,
pipeline: pipeline, pipeline: pipeline,
stage: 'deploy') stage: 'deploy')
end 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) service.execute(build)
expect(subsequent_build.reload).to be_created expect(subsequent_build.reload).to be_created
expect(subsequent_bridge.reload).to be_created
end end
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