diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-21 10:02:12 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-21 10:08:58 +0200 |
commit | 4f6bd53ce4558b3b121f1b6602c201919c8542ec (patch) | |
tree | 200ffd6f318543c733ab9e584829a7a038e94b1c | |
parent | d6b090d7582736694683f64c413424fa14812bd6 (diff) | |
download | gitlab-ce-improve-async-pipeline-processing.tar.gz |
Execute lock only when it makes senseimprove-async-pipeline-processing
-rw-r--r-- | app/models/ci/pipeline.rb | 24 | ||||
-rw-r--r-- | app/services/ci/process_pipeline_service.rb | 2 |
2 files changed, 20 insertions, 6 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index e75fe6c222b..26f1c00286c 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -30,23 +30,23 @@ module Ci end event :run do - transition any => :running + transition any - [:running] => :running end event :skip do - transition any => :skipped + transition any - [:skipped] => :skipped end event :drop do - transition any => :failed + transition any - [:failed] => :failed end event :succeed do - transition any => :success + transition any - [:success] => :success end event :cancel do - transition any => :canceled + transition any - [:canceled] => :canceled end # IMPORTANT @@ -263,6 +263,20 @@ module Ci end def update_status + reload + + can_update = + case latest_builds_status + when 'pending' then can_enqueue? + when 'running' then can_run? + when 'success' then can_succeed? + when 'failed' then can_drop? + when 'canceled' then can_cancel? + when 'skipped' then can_skip? + end + + return unless can_update + with_lock do case latest_builds_status when 'pending' then enqueue diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb index e7a422f9d28..3b255dcc803 100644 --- a/app/services/ci/process_pipeline_service.rb +++ b/app/services/ci/process_pipeline_service.rb @@ -15,7 +15,7 @@ module Ci process_stage(index) end - @pipeline.update_status if new_builds.flatten.any? + @pipeline.update_status new_builds.flatten.any? end |