Commit f932aea5 authored by Stan Hu's avatar Stan Hu

Prevent retried builds from being retried again

Previously if a build were retried, we would still allow it to be
retried again. While this is convenient for running a build again, it
also means that a build can be retried again even if there is another
build running.

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/331361

Changelog: changed
parent 3701748a
......@@ -469,7 +469,13 @@ module Ci
end
def retryable?
!archived? && (success? || failed? || canceled?)
if Feature.enabled?(:prevent_retry_of_retried_jobs, project, default_enabled: :yaml)
return false if retried? || archived?
success? || failed? || canceled?
else
!archived? && (success? || failed? || canceled?)
end
end
def retries_count
......
---
name: prevent_retry_of_retried_jobs
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62349
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/331695
milestone: '14.0'
type: development
group: group::continuous integration
default_enabled: false
......@@ -1880,6 +1880,26 @@ RSpec.describe Ci::Build do
it { is_expected.not_to be_retryable }
end
context 'when a canceled build has been retried already' do
before do
project.add_developer(user)
build.cancel!
described_class.retry(build, user)
end
context 'when prevent_retry_of_retried_jobs feature flag is enabled' do
it { is_expected.not_to be_retryable }
end
context 'when prevent_retry_of_retried_jobs feature flag is disabled' do
before do
stub_feature_flags(prevent_retry_of_retried_jobs: false)
end
it { is_expected.to be_retryable }
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