diff options
author | Rémy Coutable <remy@rymai.me> | 2016-09-20 13:34:53 +0000 |
---|---|---|
committer | Ruben Davila <rdavila84@gmail.com> | 2016-09-20 10:54:02 -0500 |
commit | 7223041221d1a535d70d1efd24f17640f1a18e6d (patch) | |
tree | a683550b6d2a74831cdd6f6ce495686d0316f74f | |
parent | 5aac551da0ec0ef968a089d562ebdfb52eabc947 (diff) | |
download | gitlab-ce-7223041221d1a535d70d1efd24f17640f1a18e6d.tar.gz |
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
-rw-r--r-- | app/models/ci/pipeline.rb | 17 | ||||
-rw-r--r-- | app/models/commit_status.rb | 8 |
2 files changed, 14 insertions, 11 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 70647b8532b..895eac1a258 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -242,13 +242,16 @@ module Ci end def build_updated - case latest_builds_status - when 'pending' then enqueue - when 'running' then run - when 'success' then succeed - when 'failed' then drop - when 'canceled' then cancel - when 'skipped' then skip + with_lock do + reload + case latest_builds_status + when 'pending' then enqueue + when 'running' then run + when 'success' then succeed + when 'failed' then drop + when 'canceled' then cancel + when 'skipped' then skip + end end end diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index c85561291c8..736db1ab0f6 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -69,15 +69,15 @@ class CommitStatus < ActiveRecord::Base commit_status.update_attributes finished_at: Time.now 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| commit_status.pipeline.try(:process!) true 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| MergeRequests::MergeWhenBuildSucceedsService.new(commit_status.pipeline.project, nil).trigger(commit_status) end |