Commit 72e97ebc authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'ensure_project_iid_before_pipeline' into 'master'

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

See merge request gitlab-org/gitlab!59341
parents 87c00c29 4d85f7ed
......@@ -28,6 +28,13 @@ module Ci
def create_pipeline!
build_pipeline.tap do |pipeline|
pipeline.stages << terminal_stage_seed(pipeline).to_resource
if Feature.enabled?(:ci_pipeline_ensure_iid_on_save, 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 save! which it will lock the InternalId row for the whole transaction
pipeline.ensure_project_iid!
end
pipeline.save!
Ci::ProcessPipelineService
......
---
name: ci_pipeline_ensure_iid_on_save
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/59341
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/327662
milestone: '13.12'
type: development
group: group::code review
default_enabled: false
......@@ -21,6 +21,23 @@ RSpec.describe Ci::CreateWebIdeTerminalService do
expect(subject[:pipeline].stages.count).to eq(1)
expect(subject[:pipeline].builds.count).to eq(1)
end
it 'calls ensure_project_iid explicitly' do
expect_next_instance_of(Ci::Pipeline) do |instance|
expect(instance).to receive(:ensure_project_iid!).twice
end
subject
end
context 'when the ci_pipeline_ensure_iid_on_save feature flag is off' do
it 'does not call ensure_project_iid explicitly' do
stub_feature_flags(ci_pipeline_ensure_iid_on_save: false)
expect_next_instance_of(Ci::Pipeline) do |instance|
expect(instance).to receive(:ensure_project_iid!).once
end
subject
end
end
end
before 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