Commit d633bc81 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Rename job_upper_timeout to maximum_job_timeout

parent a4ea9a93
...@@ -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
......
...@@ -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
......
...@@ -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
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
%th Description %th Description
%th Version %th Version
%th IP Address %th IP Address
%th Timeout %th Maximum timeout
%th Projects %th Projects
%th Jobs %th Jobs
%th Tags %th Tags
......
...@@ -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
......
...@@ -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|
......
...@@ -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
......
class AddJobUpperTimeoutToCiRunners < ActiveRecord::Migration class AddMaximumJobTimeoutToCiRunners < 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
...@@ -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
......
...@@ -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
} }
``` ```
......
...@@ -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
......
...@@ -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 =
......
...@@ -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
......
...@@ -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
......
...@@ -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
......
...@@ -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
......
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment