summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2016-10-06 08:42:35 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2016-10-06 08:42:35 +0000
commit0bbeff3d5e6c1b5ea3b364f052ed6f777c3aa645 (patch)
treec6c96df68d5666875b1c141be191448fa55aa510 /app/models
parentf90b5d5d438e77a6e849f1cc2a3b27fd1dac7ec4 (diff)
parent7f270d041da55e1fd5c378dcf2291ba752a9114d (diff)
downloadgitlab-ce-0bbeff3d5e6c1b5ea3b364f052ed6f777c3aa645.tar.gz
Merge branch 'feature/improve-async-pipeline-processing' into 'master'
Improve asynchronous pipeline processing ## What does this MR do? This MR improves asynchronous processing of pipeline. ## Why was this MR needed? It eliminates some race conditions and improves performance. ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - Tests - [x] Added for this feature/bug - [x] All builds are passing ## What are the relevant issue / merge request numbers? Related merge request: !6410 Extracted from !6411 See merge request !6650
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/pipeline.rb3
-rw-r--r--app/models/commit_status.rb17
2 files changed, 12 insertions, 8 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 97df74b0cfe..2cf9892edc5 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -251,9 +251,8 @@ module Ci
Ci::ProcessPipelineService.new(project, user).execute(self)
end
- def build_updated
+ def update_status
with_lock do
- reload
case latest_builds_status
when 'pending' then enqueue
when 'running' then run
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index ee3396abe04..9fa8d17e74e 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -84,13 +84,18 @@ class CommitStatus < ActiveRecord::Base
commit_status.update_attributes finished_at: Time.now
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?
+ commit_status.pipeline.try do |pipeline|
+ break if transition.loopback?
+
+ if commit_status.complete?
+ ProcessPipelineWorker.perform_async(pipeline.id)
+ end
+
+ UpdatePipelineWorker.perform_async(pipeline.id)
+ end
+
+ true
end
after_transition [:created, :pending, :running] => :success do |commit_status|