diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-12-13 13:25:14 +0100 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-02 19:02:46 +0100 |
commit | 7ebd36e302e3e6c118f47d18d6c72a83418097d2 (patch) | |
tree | 82cd0c0a8229c40afd86824c1acc6459057d7945 | |
parent | 1a83d9387f6db91f2adae5c3d66c6e21077967bc (diff) | |
download | gitlab-ce-7ebd36e302e3e6c118f47d18d6c72a83418097d2.tar.gz |
Prefer to use after_transitionuse-after-transition
Before_transition does not play nice when used with
OptimisticLocking and this can result in triggering
multiple events
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/55306
-rw-r--r-- | app/models/ci/build.rb | 4 | ||||
-rw-r--r-- | app/models/clusters/applications/ingress.rb | 2 | ||||
-rw-r--r-- | app/models/clusters/applications/knative.rb | 2 | ||||
-rw-r--r-- | app/models/merge_request.rb | 2 |
4 files changed, 8 insertions, 2 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 16a72c680fa..5ac521b049a 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -220,6 +220,10 @@ module Ci next unless build.project build.deployment&.drop + end + + after_transition any => [:failed] do |build| + next unless build.project if build.retry_failure? begin diff --git a/app/models/clusters/applications/ingress.rb b/app/models/clusters/applications/ingress.rb index 8f8790585a3..7799f069742 100644 --- a/app/models/clusters/applications/ingress.rb +++ b/app/models/clusters/applications/ingress.rb @@ -23,7 +23,7 @@ module Clusters FETCH_IP_ADDRESS_DELAY = 30.seconds state_machine :status do - before_transition any => [:installed] do |application| + after_transition any => [:installed] do |application| application.run_after_commit do ClusterWaitForIngressIpAddressWorker.perform_in( FETCH_IP_ADDRESS_DELAY, application.name, application.id) diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb index 0c72d7d8340..5ac152278da 100644 --- a/app/models/clusters/applications/knative.rb +++ b/app/models/clusters/applications/knative.rb @@ -20,7 +20,7 @@ module Clusters self.reactive_cache_key = ->(knative) { [knative.class.model_name.singular, knative.id] } state_machine :status do - before_transition any => [:installed] do |application| + after_transition any => [:installed] do |application| application.run_after_commit do ClusterWaitForIngressIpAddressWorker.perform_in( FETCH_IP_ADDRESS_DELAY, application.name, application.id) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index b937bef100b..6092c56b925 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -105,7 +105,9 @@ class MergeRequest < ActiveRecord::Base before_transition any => :opened do |merge_request| merge_request.merge_jid = nil + end + after_transition any => :opened do |merge_request| merge_request.run_after_commit do UpdateHeadPipelineForMergeRequestWorker.perform_async(merge_request.id) end |