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
067f5f11
Commit
067f5f11
authored
Apr 10, 2018
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect register_job_service from pending job with queued_at=nil
parent
2cc0c692
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
app/services/ci/register_job_service.rb
app/services/ci/register_job_service.rb
+1
-1
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+23
-1
No files found.
app/services/ci/register_job_service.rb
View file @
067f5f11
...
...
@@ -110,7 +110,7 @@ module Ci
labels
=
{
shared_runner:
runner
.
shared?
,
jobs_running_for_project:
jobs_running_for_project
(
job
)
}
job_queue_duration_seconds
.
observe
(
labels
,
Time
.
now
-
job
.
queued_at
)
job_queue_duration_seconds
.
observe
(
labels
,
Time
.
now
-
job
.
queued_at
)
unless
job
.
queued_at
.
nil?
attempt_counter
.
increment
end
...
...
spec/services/ci/register_job_service_spec.rb
View file @
067f5f11
...
...
@@ -400,14 +400,16 @@ module Ci
pending_job
.
update
(
created_at:
current_time
-
3600
,
queued_at:
current_time
-
1800
)
end
shared_examples
'
metrics
collector'
do
shared_examples
'
attempt counter
collector'
do
it
'increments attempt counter'
do
allow
(
job_queue_duration_seconds
).
to
receive
(
:observe
)
expect
(
attempt_counter
).
to
receive
(
:increment
)
execute
(
runner
)
end
end
shared_examples
'jobs queueing time histogram collector'
do
it
'counts job queuing time histogram with expected labels'
do
allow
(
attempt_counter
).
to
receive
(
:increment
)
expect
(
job_queue_duration_seconds
).
to
receive
(
:observe
)
...
...
@@ -432,6 +434,11 @@ module Ci
end
end
shared_examples
'metrics collector'
do
it_behaves_like
'attempt counter collector'
it_behaves_like
'jobs queueing time histogram collector'
end
context
'when shared runner is used'
do
let
(
:runner
)
{
shared_runner
}
let
(
:expected_shared_runner
)
{
true
}
...
...
@@ -439,6 +446,21 @@ module Ci
let
(
:expected_jobs_running_for_project_third_job
)
{
2
}
it_behaves_like
'metrics collector'
context
'when pending job with queued_at=nil is used'
do
before
do
pending_job
.
update
(
queued_at:
nil
)
end
it_behaves_like
'attempt counter collector'
it
"doesn't count job queuing time histogram"
do
allow
(
attempt_counter
).
to
receive
(
:increment
)
expect
(
job_queue_duration_seconds
).
not_to
receive
(
:observe
)
execute
(
runner
)
end
end
end
context
'when specific runner is used'
do
...
...
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