diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-12-06 17:30:20 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-12-06 17:30:20 +0300 |
commit | 5ccced63122fe2d21fff7d7298db1081776193b4 (patch) | |
tree | 2230f209888e118abac7dbe13f073e0bb5195576 /lib/gitlab/ci/pipeline/chain | |
parent | 382a1ef45360b538a80fd5d34cde71f53522dc2a (diff) |
Move invalid builds counter out of the transaction
Diffstat (limited to 'lib/gitlab/ci/pipeline/chain')
-rw-r--r-- | lib/gitlab/ci/pipeline/chain/create.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/gitlab/ci/pipeline/chain/create.rb b/lib/gitlab/ci/pipeline/chain/create.rb index d5e17a123df..42ae1650437 100644 --- a/lib/gitlab/ci/pipeline/chain/create.rb +++ b/lib/gitlab/ci/pipeline/chain/create.rb @@ -17,11 +17,28 @@ module Gitlab end rescue ActiveRecord::RecordInvalid => e error("Failed to persist the pipeline: #{e}") + ensure + pipeline.builds.find_each do |build| + next if build.stage_id.present? + + invalid_builds_counter.increment(node: hostname) + end end def break? !pipeline.persisted? end + + private + + def invalid_builds_counter + @counter ||= Gitlab::Metrics + .counter(:invalid_builds_counter, 'Invalid builds counter') + end + + def hostname + @hostname ||= Socket.gethostname + end end end end |