Commit 0f51c712 authored by Patrick Bajao's avatar Patrick Bajao

Mark merge request as preparing on create

When a merge request is created, we set the `merge_status` to
`preparing` so we don't check its mergeable or mark it as mergeable
until it's fully prepared.

This prevents race condition like asynchronous pipeline creation
which can lead to inconsistent behavior.
parent 8a31f66b
...@@ -14,6 +14,8 @@ module MergeRequests ...@@ -14,6 +14,8 @@ module MergeRequests
end end
def after_create(issuable) def after_create(issuable)
issuable.mark_as_preparing
# Add new items to MergeRequests::AfterCreateService if they can # Add new items to MergeRequests::AfterCreateService if they can
# be performed in Sidekiq # be performed in Sidekiq
NewMergeRequestWorker.perform_async(issuable.id, current_user.id) NewMergeRequestWorker.perform_async(issuable.id, current_user.id)
......
---
title: Mark merge request as preparing on create
merge_request: 56086
author:
type: other
...@@ -57,6 +57,10 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do ...@@ -57,6 +57,10 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do
expect(Event.where(attributes).count).to eq(1) expect(Event.where(attributes).count).to eq(1)
end end
it 'sets the merge_status to preparing' do
expect(merge_request.reload).to be_preparing
end
describe 'when marked with /wip' do describe 'when marked with /wip' do
context 'in title and in description' do context 'in title and in description' do
let(:opts) do let(:opts) 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