Commit 92c4930b authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'ensure_project_iid_before_skip_pipeline' into 'master'

Ensure the pipeline's iid is set before skipping [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!59342
parents 72e97ebc 63b8dcea
---
name: ci_pipeline_ensure_iid_on_skip
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/59342
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/327661
milestone: '13.12'
type: development
group: group::code review
default_enabled: false
......@@ -11,7 +11,16 @@ module Gitlab
def perform!
if skipped?
@pipeline.skip if @command.save_incompleted
if @command.save_incompleted
if Feature.enabled?(:ci_pipeline_ensure_iid_on_skip, @pipeline.project, default_enabled: :yaml)
# Project iid must be called outside a transaction, so we ensure it is set here
# otherwise it may be set within the state transition transaction of the skip call
# which it will lock the InternalId row for the whole transaction
@pipeline.ensure_project_iid!
end
@pipeline.skip
end
end
end
......
......@@ -21,17 +21,37 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Skip do
before do
allow(pipeline).to receive(:git_commit_message)
.and_return('commit message [ci skip]')
step.perform!
end
it 'breaks the chain' do
step.perform!
expect(step.break?).to be true
end
it 'skips the pipeline' do
step.perform!
expect(pipeline.reload).to be_skipped
end
it 'calls ensure_project_iid explicitly' do
expect(pipeline).to receive(:ensure_project_iid!)
step.perform!
end
context 'when the ci_pipeline_ensure_iid_on_save feature flag is off' do
before do
stub_feature_flags(ci_pipeline_ensure_iid_on_skip: false)
end
it 'does not call ensure_project_iid explicitly' do
expect(pipeline).not_to receive(:ensure_project_iid!)
step.perform!
end
end
end
context 'when pipeline has not been skipped' do
......
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