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
78a4189e
Commit
78a4189e
authored
Feb 21, 2018
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show timeout information on job's page
parent
d633bc81
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
84 additions
and
20 deletions
+84
-20
app/assets/javascripts/jobs/components/sidebar_details_block.vue
...ets/javascripts/jobs/components/sidebar_details_block.vue
+15
-0
app/models/ci/build.rb
app/models/ci/build.rb
+9
-3
app/serializers/build_details_entity.rb
app/serializers/build_details_entity.rb
+5
-0
db/migrate/20180221022556_add_used_timeout_and_timeout_source_columns_to_ci_builds.rb
...d_used_timeout_and_timeout_source_columns_to_ci_builds.rb
+15
-0
db/schema.rb
db/schema.rb
+2
-0
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+2
-0
spec/models/concerns/chronic_duration_attribute_spec.rb
spec/models/concerns/chronic_duration_attribute_spec.rb
+34
-16
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+2
-1
No files found.
app/assets/javascripts/jobs/components/sidebar_details_block.vue
View file @
78a4189e
...
...
@@ -39,6 +39,15 @@
runnerId
()
{
return
`#
${
this
.
job
.
runner
.
id
}
`
;
},
timeout
()
{
let
t
=
`
${
this
.
job
.
timeout
.
value
}
`
;
if
(
this
.
job
.
timeout
.
source
!=
null
)
{
t
+=
` (from
${
this
.
job
.
timeout
.
source
}
)`
;
}
return
t
;
},
renderBlock
()
{
return
this
.
job
.
merge_request
||
this
.
job
.
duration
||
...
...
@@ -114,6 +123,12 @@
title=
"Queued"
:value=
"queued"
/>
<detail-row
class=
"js-job-timeout"
v-if=
"job.timeout"
title=
"Timeout"
:value=
"timeout"
/>
<detail-row
class=
"js-job-runner"
v-if=
"job.runner"
...
...
app/models/ci/build.rb
View file @
78a4189e
...
...
@@ -6,6 +6,7 @@ module Ci
include
ObjectStorage
::
BackgroundMove
include
Presentable
include
Importable
include
ChronicDurationAttribute
MissingDependenciesError
=
Class
.
new
(
StandardError
)
...
...
@@ -90,6 +91,8 @@ module Ci
after_commit
:update_project_statistics_after_save
,
on:
[
:create
,
:update
]
after_commit
:update_project_statistics
,
on: :destroy
chronic_duration_attribute_reader
:used_timeout_user_readable
,
:used_timeout
class
<<
self
# This is needed for url_for to work,
# as the controller is JobsController
...
...
@@ -120,6 +123,10 @@ module Ci
end
after_transition
pending: :running
do
|
build
|
build
.
used_timeout
=
build
.
timeout
build
.
timeout_source
=
build
.
should_use_runner_timeout?
?
'Runner'
:
'Project'
build
.
save!
build
.
run_after_commit
do
BuildHooksWorker
.
perform_async
(
id
)
end
...
...
@@ -232,15 +239,14 @@ module Ci
end
def
timeout
return
runner
.
maximum_job_timeout
if
should_use_runner_timeout
return
runner
.
maximum_job_timeout
if
should_use_runner_timeout
?
project
.
build_timeout
end
def
should_use_runner_timeout
def
should_use_runner_timeout
?
!
runner
.
nil?
&&
runner
.
defines_maximum_job_timeout?
&&
runner
.
maximum_job_timeout
<
project
.
build_timeout
end
private
:should_use_runner_timeout
def
triggered_by?
(
current_user
)
user
==
current_user
...
...
app/serializers/build_details_entity.rb
View file @
78a4189e
...
...
@@ -5,6 +5,11 @@ class BuildDetailsEntity < JobEntity
expose
:runner
,
using:
RunnerEntity
expose
:pipeline
,
using:
PipelineEntity
expose
:timeout
,
if:
->
(
*
)
{
!
build
.
used_timeout
.
nil?
}
do
|
build
|
{
value:
build
.
used_timeout_user_readable
,
source:
build
.
timeout_source
}
end
expose
:erased_by
,
if:
->
(
*
)
{
build
.
erased?
},
using:
UserEntity
expose
:erase_path
,
if:
->
(
*
)
{
build
.
erasable?
&&
can?
(
current_user
,
:erase_build
,
build
)
}
do
|
build
|
erase_project_job_path
(
project
,
build
)
...
...
db/migrate/20180221022556_add_used_timeout_and_timeout_source_columns_to_ci_builds.rb
0 → 100644
View file @
78a4189e
class
AddUsedTimeoutAndTimeoutSourceColumnsToCiBuilds
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
up
add_column
:ci_builds
,
:used_timeout
,
:integer
add_column
:ci_builds
,
:timeout_source
,
:string
end
def
down
remove_column
:ci_builds
,
:used_timeout
remove_column
:ci_builds
,
:timeout_source
end
end
db/schema.rb
View file @
78a4189e
...
...
@@ -311,6 +311,8 @@ ActiveRecord::Schema.define(version: 20180327101207) do
t
.
integer
"artifacts_metadata_store"
t
.
boolean
"protected"
t
.
integer
"failure_reason"
t
.
integer
"used_timeout"
t
.
string
"timeout_source"
end
add_index
"ci_builds"
,
[
"artifacts_expire_at"
],
name:
"index_ci_builds_on_artifacts_expire_at"
,
where:
"(artifacts_file <> ''::text)"
,
using: :btree
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
78a4189e
...
...
@@ -283,6 +283,8 @@ CommitStatus:
-
retried
-
protected
-
failure_reason
-
used_timeout
-
timeout_source
Ci::Variable:
-
id
-
project_id
...
...
spec/models/concerns/chronic_duration_attribute_spec.rb
View file @
78a4189e
require
'spec_helper'
shared_examples
'ChronicDurationAttribute'
do
describe
'dynamically defined methods'
do
it
{
expect
(
subject
.
class
).
to
be_public_method_defined
(
virtual_field
)
}
it
{
expect
(
subject
.
class
).
to
be_public_method_defined
(
"
#{
virtual_field
}
="
)
}
it
'parses chronic duration input'
do
subject
.
send
(
"
#{
virtual_field
}
="
,
"10m"
)
expect
(
subject
.
send
(
source_field
)).
to
eq
(
600
)
shared_examples
'ChronicDurationAttribute reader'
do
it
'contains dynamically created reader method'
do
expect
(
subject
.
class
).
to
be_public_method_defined
(
virtual_field
)
end
it
'outputs chronic duration formated value'
do
...
...
@@ -16,13 +10,37 @@ shared_examples 'ChronicDurationAttribute' do
expect
(
subject
.
send
(
virtual_field
)).
to
eq
(
'2m'
)
end
end
shared_examples
'ChronicDurationAttribute writer'
do
it
'contains dynamically created writer method'
do
expect
(
subject
.
class
).
to
be_public_method_defined
(
"
#{
virtual_field
}
="
)
end
it
'parses chronic duration input'
do
subject
.
send
(
"
#{
virtual_field
}
="
,
"10m"
)
expect
(
subject
.
send
(
source_field
)).
to
eq
(
600
)
end
end
describe
'ChronicDurationAttribute'
do
let
(
:source_field
)
{
:maximum_job_timeout
}
let
(
:virtual_field
)
{
:maximum_job_timeout_user_readable
}
subject
{
Ci
::
Runner
.
new
}
let
(
:source_field
)
{
:maximum_job_timeout
}
let
(
:virtual_field
)
{
:maximum_job_timeout_user_readable
}
subject
{
Ci
::
Runner
.
new
}
it_behaves_like
'ChronicDurationAttribute reader'
it_behaves_like
'ChronicDurationAttribute writer'
end
describe
'ChronicDurationAttribute - reader'
do
let
(
:source_field
)
{
:used_timeout
}
let
(
:virtual_field
)
{
:used_timeout_user_readable
}
subject
{
Ci
::
Build
.
new
}
it
"doesn't contain dynamically created writer method"
do
expect
(
subject
.
class
).
not_to
be_public_method_defined
(
"
#{
virtual_field
}
="
)
end
it_behaves_like
'ChronicDurationAttribute'
it_behaves_like
'ChronicDurationAttribute
reader
'
end
spec/services/ci/retry_build_service_spec.rb
View file @
78a4189e
...
...
@@ -29,7 +29,8 @@ describe Ci::RetryBuildService do
commit_id deployments erased_by_id last_deployment project_id
runner_id tag_taggings taggings tags trigger_request_id
user_id auto_canceled_by_id retried failure_reason
artifacts_file_store artifacts_metadata_store]
.
freeze
artifacts_file_store artifacts_metadata_store
used_timeout timeout_source]
.
freeze
shared_examples
'build duplication'
do
let
(
:another_pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
...
...
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