Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-09-20 16:34:53 +0300
committerRémy Coutable <remy@rymai.me>2016-09-20 16:34:53 +0300
commit9eed4a8dc2c9a99368ee778946af39578866b066 (patch)
treef3d4bd5ce20af200512a17612038eda45072a6e7 /app
parentf30005f0a99b6ab019af22a8b7db40aecd1ff066 (diff)
parentc826ad455018deccdb66a64dcb72ce8d4b177a99 (diff)
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
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/pipeline.rb17
-rw-r--r--app/models/commit_status.rb8
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