BigW Consortium Gitlab

Rename job_upper_timeout to maximum_job_timeout

parent a4ea9a93
......@@ -232,13 +232,13 @@ module Ci
end
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
end
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
private :should_use_runner_timeout
......
......@@ -9,7 +9,7 @@ module Ci
ONLINE_CONTACT_TIMEOUT = 1.hour
UPDATE_DB_RUNNER_INFO_EVERY = 40.minutes
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 :runner_projects, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
......@@ -52,7 +52,7 @@ module Ci
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.
#
......@@ -170,8 +170,8 @@ module Ci
end
end
def defines_job_upper_timeout?
job_upper_timeout && job_upper_timeout > 0
def defines_maximum_job_timeout?
!maximum_job_timeout.nil? && maximum_job_timeout > 0
end
private
......
......@@ -19,8 +19,8 @@
%td
= runner.ip_address
%td
- if runner.defines_job_upper_timeout?
= runner.job_upper_timeout
- if runner.defines_maximum_job_timeout?
= runner.maximum_job_timeout_user_readable
- else
n/a
%td
......
......@@ -61,7 +61,7 @@
%th Description
%th Version
%th IP Address
%th Timeout
%th Maximum timeout
%th Projects
%th Jobs
%th Tags
......
......@@ -40,10 +40,10 @@
.col-sm-10
= f.text_field :description, class: 'form-control'
.form-group
= label_tag :job_upper_timeout, class: 'control-label' do
Job upper timeout
= label_tag :maximum_job_timeout_user_readable, class: 'control-label' do
Maximum job timeout
.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
.form-group
= label_tag :tag_list, class: 'control-label' do
......
......@@ -36,8 +36,8 @@
- if runner.description.present?
%p.runner-description
= runner.description
- if runner.defines_job_upper_timeout?
%p Job upper timeout: #{runner.job_upper_timeout}
- if runner.defines_maximum_job_timeout?
%p Maximum job timeout: #{runner.maximum_job_timeout_user_readable}
- if runner.tag_list.present?
%p
- runner.tag_list.sort.each do |tag|
......
......@@ -56,8 +56,8 @@
%td Description
%td= @runner.description
%tr
%td Job upper timeout
%td= @runner.job_upper_timeout
%td Maximum job timeout
%td= @runner.maximum_job_timeout_user_readable
%tr
%td Last contact
%td
......
class AddJobUpperTimeoutToCiRunners < ActiveRecord::Migration
class AddMaximumJobTimeoutToCiRunners < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
add_column :ci_runners, :job_upper_timeout, :integer
add_column :ci_runners, :maximum_job_timeout, :integer
end
def down
remove_column :ci_runners, :job_upper_timeout
remove_column :ci_runners, :maximum_job_timeout
end
end
......@@ -459,7 +459,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do
t.boolean "locked", default: false, null: false
t.integer "access_level", default: 0, null: false
t.string "ip_address"
t.integer "job_upper_timeout"
t.integer "maximum_job_timeout"
end
add_index "ci_runners", ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree
......
......@@ -154,7 +154,7 @@ Example response:
],
"version": null,
"access_level": "ref_protected",
"job_upper_timeout": 3600
"maximum_job_timeout": 3600
}
```
......@@ -175,7 +175,7 @@ PUT /runners/:id
| `run_untagged` | boolean | no | Flag indicating the runner can execute untagged jobs |
| `locked` | boolean | no | Flag indicating the runner is locked |
| `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"
......@@ -214,7 +214,7 @@ Example response:
],
"version": null,
"access_level": "ref_protected",
"job_upper_timeout": null
"maximum_job_timeout": null
}
```
......
......@@ -951,7 +951,7 @@ module API
expose :tag_list
expose :run_untagged
expose :locked
expose :job_upper_timeout
expose :maximum_job_timeout
expose :access_level
expose :version, :revision, :platform, :architecture
expose :contacted_at
......
......@@ -14,10 +14,10 @@ module API
optional :locked, type: Boolean, desc: 'Should Runner be locked for current project'
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 :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
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)
runner =
......
......@@ -57,7 +57,7 @@ module API
optional :locked, type: Boolean, desc: 'Flag indicating the runner is locked'
optional :access_level, type: String, values: Ci::Runner.access_levels.keys,
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
end
put ':id' do
......
......@@ -1281,7 +1281,7 @@ describe Ci::Build do
end
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) }
it 'returns project timeout configuration' do
......@@ -1290,11 +1290,11 @@ describe Ci::Build do
end
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) }
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
......
......@@ -556,20 +556,20 @@ describe Ci::Runner do
end
end
describe '#defines_job_upper_timeout?' do
context 'when job upper timeout is specified' do
subject { create(:ci_runner, job_upper_timeout: 1234) }
describe '#defines_maximum_job_timeout?' do
context 'when maximum job timeout is specified' do
subject { create(:ci_runner, maximum_job_timeout: 1234) }
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
context 'when job upper timeout is not specified' do
context 'when maximum job timeout is not specified' do
subject { create(:ci_runner) }
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
......
......@@ -109,13 +109,13 @@ describe API::Runner do
end
end
context 'when job upper timeout is specified' do
context 'when maximum job timeout is specified' do
it 'creates runner' do
post api('/runners'), token: registration_token,
job_upper_timeout: 7200
maximum_job_timeout: 7200
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
......@@ -671,7 +671,7 @@ describe API::Runner do
end
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
request_job
......@@ -682,7 +682,7 @@ describe API::Runner do
end
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
request_job
......
......@@ -123,7 +123,7 @@ describe API::Runners do
expect(response).to have_gitlab_http_status(200)
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
......@@ -194,7 +194,7 @@ describe API::Runners do
run_untagged: 'false',
locked: 'true',
access_level: 'ref_protected',
job_upper_timeout: 1234 )
maximum_job_timeout: 1234 )
shared_runner.reload
expect(response).to have_gitlab_http_status(200)
......@@ -206,7 +206,7 @@ describe API::Runners do
expect(shared_runner.ref_protected?).to be_truthy
expect(shared_runner.ensure_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
......
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