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
d633bc81
Commit
d633bc81
authored
Feb 21, 2018
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename job_upper_timeout to maximum_job_timeout
parent
a4ea9a93
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
54 additions
and
41 deletions
+54
-41
app/models/ci/build.rb
app/models/ci/build.rb
+2
-2
app/models/ci/runner.rb
app/models/ci/runner.rb
+4
-4
app/views/admin/runners/_runner.html.haml
app/views/admin/runners/_runner.html.haml
+2
-2
app/views/admin/runners/index.html.haml
app/views/admin/runners/index.html.haml
+1
-1
app/views/projects/runners/_form.html.haml
app/views/projects/runners/_form.html.haml
+3
-3
app/views/projects/runners/_runner.html.haml
app/views/projects/runners/_runner.html.haml
+2
-2
app/views/projects/runners/show.html.haml
app/views/projects/runners/show.html.haml
+2
-2
db/migrate/20180219153455_add_maximum_job_timeout_to_ci_runners.rb
...e/20180219153455_add_maximum_job_timeout_to_ci_runners.rb
+13
-0
db/schema.rb
db/schema.rb
+1
-1
doc/api/runners.md
doc/api/runners.md
+3
-3
lib/api/entities.rb
lib/api/entities.rb
+1
-1
lib/api/runner.rb
lib/api/runner.rb
+2
-2
lib/api/runners.rb
lib/api/runners.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+3
-3
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+6
-6
spec/requests/api/runner_spec.rb
spec/requests/api/runner_spec.rb
+5
-5
spec/requests/api/runners_spec.rb
spec/requests/api/runners_spec.rb
+3
-3
No files found.
app/models/ci/build.rb
View file @
d633bc81
...
@@ -232,13 +232,13 @@ module Ci
...
@@ -232,13 +232,13 @@ module Ci
end
end
def
timeout
def
timeout
return
runner
.
job_upper
_timeout
if
should_use_runner_timeout
return
runner
.
maximum_job
_timeout
if
should_use_runner_timeout
project
.
build_timeout
project
.
build_timeout
end
end
def
should_use_runner_timeout
def
should_use_runner_timeout
runner
&&
runner
.
defines_job_upper_timeout?
&&
runner
.
job_upper
_timeout
<
project
.
build_timeout
!
runner
.
nil?
&&
runner
.
defines_maximum_job_timeout?
&&
runner
.
maximum_job
_timeout
<
project
.
build_timeout
end
end
private
:should_use_runner_timeout
private
:should_use_runner_timeout
...
...
app/models/ci/runner.rb
View file @
d633bc81
...
@@ -9,7 +9,7 @@ module Ci
...
@@ -9,7 +9,7 @@ module Ci
ONLINE_CONTACT_TIMEOUT
=
1
.
hour
ONLINE_CONTACT_TIMEOUT
=
1
.
hour
UPDATE_DB_RUNNER_INFO_EVERY
=
40
.
minutes
UPDATE_DB_RUNNER_INFO_EVERY
=
40
.
minutes
AVAILABLE_SCOPES
=
%w[specific shared active paused online]
.
freeze
AVAILABLE_SCOPES
=
%w[specific shared active paused online]
.
freeze
FORM_EDITABLE
=
%i[description tag_list active run_untagged locked access_level
job_upper_timeout
]
.
freeze
FORM_EDITABLE
=
%i[description tag_list active run_untagged locked access_level
maximum_job_timeout_user_readable
]
.
freeze
has_many
:builds
has_many
:builds
has_many
:runner_projects
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_many
:runner_projects
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
...
@@ -52,7 +52,7 @@ module Ci
...
@@ -52,7 +52,7 @@ module Ci
cached_attr_reader
:version
,
:revision
,
:platform
,
:architecture
,
:contacted_at
,
:ip_address
cached_attr_reader
:version
,
:revision
,
:platform
,
:architecture
,
:contacted_at
,
:ip_address
chronic_duration_attribute
:
job_upper_timeout_user_readable
,
:job_upper
_timeout
chronic_duration_attribute
:
maximum_job_timeout_user_readable
,
:maximum_job
_timeout
# Searches for runners matching the given query.
# Searches for runners matching the given query.
#
#
...
@@ -170,8 +170,8 @@ module Ci
...
@@ -170,8 +170,8 @@ module Ci
end
end
end
end
def
defines_
job_upper
_timeout?
def
defines_
maximum_job
_timeout?
job_upper_timeout
&&
job_upper
_timeout
>
0
!
maximum_job_timeout
.
nil?
&&
maximum_job
_timeout
>
0
end
end
private
private
...
...
app/views/admin/runners/_runner.html.haml
View file @
d633bc81
...
@@ -19,8 +19,8 @@
...
@@ -19,8 +19,8 @@
%td
%td
=
runner
.
ip_address
=
runner
.
ip_address
%td
%td
-
if
runner
.
defines_
job_upper
_timeout?
-
if
runner
.
defines_
maximum_job
_timeout?
=
runner
.
job_upper_timeout
=
runner
.
maximum_job_timeout_user_readable
-
else
-
else
n/a
n/a
%td
%td
...
...
app/views/admin/runners/index.html.haml
View file @
d633bc81
...
@@ -61,7 +61,7 @@
...
@@ -61,7 +61,7 @@
%th
Description
%th
Description
%th
Version
%th
Version
%th
IP Address
%th
IP Address
%th
T
imeout
%th
Maximum t
imeout
%th
Projects
%th
Projects
%th
Jobs
%th
Jobs
%th
Tags
%th
Tags
...
...
app/views/projects/runners/_form.html.haml
View file @
d633bc81
...
@@ -40,10 +40,10 @@
...
@@ -40,10 +40,10 @@
.col-sm-10
.col-sm-10
=
f
.
text_field
:description
,
class:
'form-control'
=
f
.
text_field
:description
,
class:
'form-control'
.form-group
.form-group
=
label_tag
:
job_upper_timeout
,
class:
'control-label'
do
=
label_tag
:
maximum_job_timeout_user_readable
,
class:
'control-label'
do
Job upper
timeout
Maximum job
timeout
.col-sm-10
.col-sm-10
=
f
.
text_field
:
job_upper_timeout
,
class:
'form-control'
=
f
.
text_field
:
maximum_job_timeout_user_readable
,
class:
'form-control'
.help-block
This timeout will take precedence when lower than Project-defined timeout
.help-block
This timeout will take precedence when lower than Project-defined timeout
.form-group
.form-group
=
label_tag
:tag_list
,
class:
'control-label'
do
=
label_tag
:tag_list
,
class:
'control-label'
do
...
...
app/views/projects/runners/_runner.html.haml
View file @
d633bc81
...
@@ -36,8 +36,8 @@
...
@@ -36,8 +36,8 @@
-
if
runner
.
description
.
present?
-
if
runner
.
description
.
present?
%p
.runner-description
%p
.runner-description
=
runner
.
description
=
runner
.
description
-
if
runner
.
defines_
job_upper
_timeout?
-
if
runner
.
defines_
maximum_job
_timeout?
%p
Job upper timeout:
#{
runner
.
job_upper_timeout
}
%p
Maximum job timeout:
#{
runner
.
maximum_job_timeout_user_readable
}
-
if
runner
.
tag_list
.
present?
-
if
runner
.
tag_list
.
present?
%p
%p
-
runner
.
tag_list
.
sort
.
each
do
|
tag
|
-
runner
.
tag_list
.
sort
.
each
do
|
tag
|
...
...
app/views/projects/runners/show.html.haml
View file @
d633bc81
...
@@ -56,8 +56,8 @@
...
@@ -56,8 +56,8 @@
%td
Description
%td
Description
%td
=
@runner
.
description
%td
=
@runner
.
description
%tr
%tr
%td
Job upper
timeout
%td
Maximum job
timeout
%td
=
@runner
.
job_upper_timeout
%td
=
@runner
.
maximum_job_timeout_user_readable
%tr
%tr
%td
Last contact
%td
Last contact
%td
%td
...
...
db/migrate/20180219153455_add_
job_upper
_timeout_to_ci_runners.rb
→
db/migrate/20180219153455_add_
maximum_job
_timeout_to_ci_runners.rb
View file @
d633bc81
class
Add
JobUpper
TimeoutToCiRunners
<
ActiveRecord
::
Migration
class
Add
MaximumJob
TimeoutToCiRunners
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
DOWNTIME
=
false
def
up
def
up
add_column
:ci_runners
,
:
job_upper
_timeout
,
:integer
add_column
:ci_runners
,
:
maximum_job
_timeout
,
:integer
end
end
def
down
def
down
remove_column
:ci_runners
,
:
job_upper
_timeout
remove_column
:ci_runners
,
:
maximum_job
_timeout
end
end
end
end
db/schema.rb
View file @
d633bc81
...
@@ -459,7 +459,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do
...
@@ -459,7 +459,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do
t
.
boolean
"locked"
,
default:
false
,
null:
false
t
.
boolean
"locked"
,
default:
false
,
null:
false
t
.
integer
"access_level"
,
default:
0
,
null:
false
t
.
integer
"access_level"
,
default:
0
,
null:
false
t
.
string
"ip_address"
t
.
string
"ip_address"
t
.
integer
"
job_upper
_timeout"
t
.
integer
"
maximum_job
_timeout"
end
end
add_index
"ci_runners"
,
[
"contacted_at"
],
name:
"index_ci_runners_on_contacted_at"
,
using: :btree
add_index
"ci_runners"
,
[
"contacted_at"
],
name:
"index_ci_runners_on_contacted_at"
,
using: :btree
...
...
doc/api/runners.md
View file @
d633bc81
...
@@ -154,7 +154,7 @@ Example response:
...
@@ -154,7 +154,7 @@ Example response:
],
],
"version"
:
null
,
"version"
:
null
,
"access_level"
:
"ref_protected"
,
"access_level"
:
"ref_protected"
,
"
job_upper
_timeout"
:
3600
"
maximum_job
_timeout"
:
3600
}
}
```
```
...
@@ -175,7 +175,7 @@ PUT /runners/:id
...
@@ -175,7 +175,7 @@ PUT /runners/:id
|
`run_untagged`
| boolean | no | Flag indicating the runner can execute untagged jobs |
|
`run_untagged`
| boolean | no | Flag indicating the runner can execute untagged jobs |
|
`locked`
| boolean | no | Flag indicating the runner is locked |
|
`locked`
| boolean | no | Flag indicating the runner is locked |
|
`access_level`
| string | no | The access_level of the runner;
`not_protected`
or
`ref_protected`
|
|
`access_level`
| string | no | The access_level of the runner;
`not_protected`
or
`ref_protected`
|
|
`
job_upper_timeout`
| integer | no | Upper
timeout set when this Runner will handle the job |
|
`
maximum_job_timeout`
| integer | no | Maximum
timeout set when this Runner will handle the job |
```
```
curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/runners/6" --form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"
curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/runners/6" --form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"
...
@@ -214,7 +214,7 @@ Example response:
...
@@ -214,7 +214,7 @@ Example response:
],
],
"version"
:
null
,
"version"
:
null
,
"access_level"
:
"ref_protected"
,
"access_level"
:
"ref_protected"
,
"
job_upper
_timeout"
:
null
"
maximum_job
_timeout"
:
null
}
}
```
```
...
...
lib/api/entities.rb
View file @
d633bc81
...
@@ -951,7 +951,7 @@ module API
...
@@ -951,7 +951,7 @@ module API
expose
:tag_list
expose
:tag_list
expose
:run_untagged
expose
:run_untagged
expose
:locked
expose
:locked
expose
:
job_upper
_timeout
expose
:
maximum_job
_timeout
expose
:access_level
expose
:access_level
expose
:version
,
:revision
,
:platform
,
:architecture
expose
:version
,
:revision
,
:platform
,
:architecture
expose
:contacted_at
expose
:contacted_at
...
...
lib/api/runner.rb
View file @
d633bc81
...
@@ -14,10 +14,10 @@ module API
...
@@ -14,10 +14,10 @@ module API
optional
:locked
,
type:
Boolean
,
desc:
'Should Runner be locked for current project'
optional
:locked
,
type:
Boolean
,
desc:
'Should Runner be locked for current project'
optional
:run_untagged
,
type:
Boolean
,
desc:
'Should Runner handle untagged jobs'
optional
:run_untagged
,
type:
Boolean
,
desc:
'Should Runner handle untagged jobs'
optional
:tag_list
,
type:
Array
[
String
],
desc:
%q(List of Runner's tags)
optional
:tag_list
,
type:
Array
[
String
],
desc:
%q(List of Runner's tags)
optional
:
job_upper_timeout
,
type:
Integer
,
desc:
'Upper
timeout set when this Runner will handle the job'
optional
:
maximum_job_timeout
,
type:
Integer
,
desc:
'Maximum
timeout set when this Runner will handle the job'
end
end
post
'/'
do
post
'/'
do
attributes
=
attributes_for_keys
([
:description
,
:locked
,
:run_untagged
,
:tag_list
,
:
job_upper
_timeout
])
attributes
=
attributes_for_keys
([
:description
,
:locked
,
:run_untagged
,
:tag_list
,
:
maximum_job
_timeout
])
.
merge
(
get_runner_details_from_request
)
.
merge
(
get_runner_details_from_request
)
runner
=
runner
=
...
...
lib/api/runners.rb
View file @
d633bc81
...
@@ -57,7 +57,7 @@ module API
...
@@ -57,7 +57,7 @@ module API
optional
:locked
,
type:
Boolean
,
desc:
'Flag indicating the runner is locked'
optional
:locked
,
type:
Boolean
,
desc:
'Flag indicating the runner is locked'
optional
:access_level
,
type:
String
,
values:
Ci
::
Runner
.
access_levels
.
keys
,
optional
:access_level
,
type:
String
,
values:
Ci
::
Runner
.
access_levels
.
keys
,
desc:
'The access_level of the runner'
desc:
'The access_level of the runner'
optional
:
job_upper_timeout
,
type:
Integer
,
desc:
'Upper
timeout set when this Runner will handle the job'
optional
:
maximum_job_timeout
,
type:
Integer
,
desc:
'Maximum
timeout set when this Runner will handle the job'
at_least_one_of
:description
,
:active
,
:tag_list
,
:run_untagged
,
:locked
,
:access_level
at_least_one_of
:description
,
:active
,
:tag_list
,
:run_untagged
,
:locked
,
:access_level
end
end
put
':id'
do
put
':id'
do
...
...
spec/models/ci/build_spec.rb
View file @
d633bc81
...
@@ -1281,7 +1281,7 @@ describe Ci::Build do
...
@@ -1281,7 +1281,7 @@ describe Ci::Build do
end
end
context
'when runner sets timeout to bigger value'
do
context
'when runner sets timeout to bigger value'
do
let
(
:runner2
)
{
create
(
:ci_runner
,
job_upper
_timeout:
2000
)
}
let
(
:runner2
)
{
create
(
:ci_runner
,
maximum_job
_timeout:
2000
)
}
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline2
,
runner:
runner2
)
}
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline2
,
runner:
runner2
)
}
it
'returns project timeout configuration'
do
it
'returns project timeout configuration'
do
...
@@ -1290,11 +1290,11 @@ describe Ci::Build do
...
@@ -1290,11 +1290,11 @@ describe Ci::Build do
end
end
context
'when runner sets timeout to smaller value'
do
context
'when runner sets timeout to smaller value'
do
let
(
:runner2
)
{
create
(
:ci_runner
,
job_upper
_timeout:
500
)
}
let
(
:runner2
)
{
create
(
:ci_runner
,
maximum_job
_timeout:
500
)
}
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline2
,
runner:
runner2
)
}
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
pipeline:
pipeline2
,
runner:
runner2
)
}
it
'returns project timeout configuration'
do
it
'returns project timeout configuration'
do
expect
(
build
.
timeout
).
to
eq
(
runner2
.
job_upper
_timeout
)
expect
(
build
.
timeout
).
to
eq
(
runner2
.
maximum_job
_timeout
)
end
end
end
end
end
end
...
...
spec/models/ci/runner_spec.rb
View file @
d633bc81
...
@@ -556,20 +556,20 @@ describe Ci::Runner do
...
@@ -556,20 +556,20 @@ describe Ci::Runner do
end
end
end
end
describe
'#defines_
job_upper
_timeout?'
do
describe
'#defines_
maximum_job
_timeout?'
do
context
'when
job upper
timeout is specified'
do
context
'when
maximum job
timeout is specified'
do
subject
{
create
(
:ci_runner
,
job_upper
_timeout:
1234
)
}
subject
{
create
(
:ci_runner
,
maximum_job
_timeout:
1234
)
}
it
'should return true'
do
it
'should return true'
do
expect
(
subject
.
defines_
job_upper
_timeout?
).
to
be_truthy
expect
(
subject
.
defines_
maximum_job
_timeout?
).
to
be_truthy
end
end
end
end
context
'when
job upper
timeout is not specified'
do
context
'when
maximum job
timeout is not specified'
do
subject
{
create
(
:ci_runner
)
}
subject
{
create
(
:ci_runner
)
}
it
'should return false'
do
it
'should return false'
do
expect
(
subject
.
defines_
job_upper
_timeout?
).
to
be_falsey
expect
(
subject
.
defines_
maximum_job
_timeout?
).
to
be_falsey
end
end
end
end
end
end
...
...
spec/requests/api/runner_spec.rb
View file @
d633bc81
...
@@ -109,13 +109,13 @@ describe API::Runner do
...
@@ -109,13 +109,13 @@ describe API::Runner do
end
end
end
end
context
'when
job upper
timeout is specified'
do
context
'when
maximum job
timeout is specified'
do
it
'creates runner'
do
it
'creates runner'
do
post
api
(
'/runners'
),
token:
registration_token
,
post
api
(
'/runners'
),
token:
registration_token
,
job_upper
_timeout:
7200
maximum_job
_timeout:
7200
expect
(
response
).
to
have_gitlab_http_status
201
expect
(
response
).
to
have_gitlab_http_status
201
expect
(
Ci
::
Runner
.
first
.
job_upper
_timeout
).
to
eq
(
7200
)
expect
(
Ci
::
Runner
.
first
.
maximum_job
_timeout
).
to
eq
(
7200
)
end
end
end
end
...
@@ -671,7 +671,7 @@ describe API::Runner do
...
@@ -671,7 +671,7 @@ describe API::Runner do
end
end
context
'when runner specifies lower timeout'
do
context
'when runner specifies lower timeout'
do
let
(
:runner
)
{
create
(
:ci_runner
,
job_upper
_timeout:
1000
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
maximum_job
_timeout:
1000
)
}
it
'contains info about timeout overridden by runner'
do
it
'contains info about timeout overridden by runner'
do
request_job
request_job
...
@@ -682,7 +682,7 @@ describe API::Runner do
...
@@ -682,7 +682,7 @@ describe API::Runner do
end
end
context
'when runner specifies bigger timeout'
do
context
'when runner specifies bigger timeout'
do
let
(
:runner
)
{
create
(
:ci_runner
,
job_upper
_timeout:
2000
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
maximum_job
_timeout:
2000
)
}
it
'contains info about timeout not overridden by runner'
do
it
'contains info about timeout not overridden by runner'
do
request_job
request_job
...
...
spec/requests/api/runners_spec.rb
View file @
d633bc81
...
@@ -123,7 +123,7 @@ describe API::Runners do
...
@@ -123,7 +123,7 @@ describe API::Runners do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'description'
]).
to
eq
(
shared_runner
.
description
)
expect
(
json_response
[
'description'
]).
to
eq
(
shared_runner
.
description
)
expect
(
json_response
[
'
job_upper
_timeout'
]).
to
be_nil
expect
(
json_response
[
'
maximum_job
_timeout'
]).
to
be_nil
end
end
end
end
...
@@ -194,7 +194,7 @@ describe API::Runners do
...
@@ -194,7 +194,7 @@ describe API::Runners do
run_untagged:
'false'
,
run_untagged:
'false'
,
locked:
'true'
,
locked:
'true'
,
access_level:
'ref_protected'
,
access_level:
'ref_protected'
,
job_upper
_timeout:
1234
)
maximum_job
_timeout:
1234
)
shared_runner
.
reload
shared_runner
.
reload
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
...
@@ -206,7 +206,7 @@ describe API::Runners do
...
@@ -206,7 +206,7 @@ describe API::Runners do
expect
(
shared_runner
.
ref_protected?
).
to
be_truthy
expect
(
shared_runner
.
ref_protected?
).
to
be_truthy
expect
(
shared_runner
.
ensure_runner_queue_value
)
expect
(
shared_runner
.
ensure_runner_queue_value
)
.
not_to
eq
(
runner_queue_value
)
.
not_to
eq
(
runner_queue_value
)
expect
(
shared_runner
.
job_upper
_timeout
).
to
eq
(
1234
)
expect
(
shared_runner
.
maximum_job
_timeout
).
to
eq
(
1234
)
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