Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
5ccced63
Commit
5ccced63
authored
Dec 06, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move invalid builds counter out of the transaction
parent
382a1ef4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
13 deletions
+17
-13
lib/gitlab/ci/pipeline/chain/create.rb
lib/gitlab/ci/pipeline/chain/create.rb
+17
-0
lib/gitlab/ci/stage/seed.rb
lib/gitlab/ci/stage/seed.rb
+0
-13
No files found.
lib/gitlab/ci/pipeline/chain/create.rb
View file @
5ccced63
...
...
@@ -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
...
...
lib/gitlab/ci/stage/seed.rb
View file @
5ccced63
...
...
@@ -39,10 +39,6 @@ module Gitlab
pipeline
.
stages
.
create!
(
stage
).
tap
do
|
stage
|
builds_attributes
=
builds
.
map
do
|
attributes
|
attributes
.
merge
(
stage_id:
stage
.
id
)
if
attributes
.
fetch
(
:stage_id
).
nil?
invalid_builds_counter
.
increment
(
node:
hostname
)
end
end
pipeline
.
builds
.
create!
(
builds_attributes
).
each
do
|
build
|
...
...
@@ -56,15 +52,6 @@ module Gitlab
def
protected_ref?
@protected_ref
||=
project
.
protected_for?
(
pipeline
.
ref
)
end
def
invalid_builds_counter
@counter
||=
Gitlab
::
Metrics
.
counter
(
:invalid_builds_counter
,
'Builds without stage assigned counter'
)
end
def
hostname
@hostname
||=
Socket
.
gethostname
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment