Commit 9eed4a8d authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-regression-in-handling-build-updated' into 'master'

Fix processing of events when build finished.

Update pipeline after processing builds. Otherwise we can get into scenario where pipeline will be marked as running.

This solves a quite significant regression in Pipeline processing.

Proper fix is to move all this to Sidekiq Worker and process pipeline there.
I'll do it after 8.12 release.

See merge request !6410
parents f30005f0 c826ad45
...@@ -242,13 +242,16 @@ module Ci ...@@ -242,13 +242,16 @@ module Ci
end end
def build_updated def build_updated
case latest_builds_status with_lock do
when 'pending' then enqueue reload
when 'running' then run case latest_builds_status
when 'success' then succeed when 'pending' then enqueue
when 'failed' then drop when 'running' then run
when 'canceled' then cancel when 'success' then succeed
when 'skipped' then skip when 'failed' then drop
when 'canceled' then cancel
when 'skipped' then skip
end
end end
end end
......
...@@ -69,15 +69,15 @@ class CommitStatus < ActiveRecord::Base ...@@ -69,15 +69,15 @@ class CommitStatus < ActiveRecord::Base
commit_status.update_attributes finished_at: Time.now commit_status.update_attributes finished_at: Time.now
end end
after_transition do |commit_status, transition|
commit_status.pipeline.try(:build_updated) unless transition.loopback?
end
after_transition any => [:success, :failed, :canceled] do |commit_status| after_transition any => [:success, :failed, :canceled] do |commit_status|
commit_status.pipeline.try(:process!) commit_status.pipeline.try(:process!)
true true
end end
after_transition do |commit_status, transition|
commit_status.pipeline.try(:build_updated) unless transition.loopback?
end
after_transition [:created, :pending, :running] => :success do |commit_status| after_transition [:created, :pending, :running] => :success do |commit_status|
MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status) MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status)
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