BigW Consortium Gitlab

Rename maximum_job_timeout to maximum_timeout

parent 1e138767
......@@ -20,7 +20,7 @@ module Ci
def save_timeout_state!
project_timeout = build.project&.build_timeout
timeout = [project_timeout, build.runner&.maximum_job_timeout].compact.min
timeout = [project_timeout, build.runner&.maximum_timeout].compact.min
self.used_timeout = timeout
self.timeout_source = timeout < project_timeout ? :runner_timeout_source : :project_timeout_source
......
......@@ -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 maximum_job_timeout_human_readable].freeze
FORM_EDITABLE = %i[description tag_list active run_untagged locked access_level maximum_timeout_human_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_attr :maximum_job_timeout_human_readable, :maximum_job_timeout
chronic_duration_attr :maximum_timeout_human_readable, :maximum_timeout
# Searches for runners matching the given query.
#
......
......@@ -40,10 +40,10 @@
.col-sm-10
= f.text_field :description, class: 'form-control'
.form-group
= label_tag :maximum_job_timeout_human_readable, class: 'control-label' do
= label_tag :maximum_timeout_human_readable, class: 'control-label' do
Maximum job timeout
.col-sm-10
= f.text_field :maximum_job_timeout_human_readable, class: 'form-control'
= f.text_field :maximum_timeout_human_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
......
......@@ -57,7 +57,7 @@
%td= @runner.description
%tr
%td Maximum job timeout
%td= @runner.maximum_job_timeout_human_readable
%td= @runner.maximum_timeout_human_readable
%tr
%td Last contact
%td
......
class AddMaximumJobTimeoutToCiRunners < ActiveRecord::Migration
class AddMaximumTimeoutToCiRunners < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :ci_runners, :maximum_job_timeout, :integer
add_column :ci_runners, :maximum_timeout, :integer
end
end
......@@ -463,7 +463,7 @@ ActiveRecord::Schema.define(version: 20180327101207) do
t.boolean "run_untagged", default: true, null: false
t.boolean "locked", default: false, null: false
t.integer "access_level", default: 0, null: false
t.integer "maximum_job_timeout"
t.integer "maximum_timeout"
t.string "ip_address"
end
......
......@@ -154,7 +154,7 @@ Example response:
],
"version": null,
"access_level": "ref_protected",
"maximum_job_timeout": 3600
"maximum_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` |
| `maximum_job_timeout` | integer | no | Maximum timeout set when this Runner will handle the job |
| `maximum_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",
"maximum_job_timeout": null
"maximum_timeout": null
}
```
......
......@@ -951,7 +951,7 @@ module API
expose :tag_list
expose :run_untagged
expose :locked
expose :maximum_job_timeout
expose :maximum_timeout
expose :access_level
expose :version, :revision, :platform, :architecture
expose :contacted_at
......
......@@ -14,12 +14,12 @@ 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 :maximum_job_timeout, type: String, desc: 'Maximum timeout set when this Runner will handle the job'
optional :maximum_timeout, type: String, desc: 'Maximum timeout set when this Runner will handle the job'
end
post '/' do
attributes = attributes_for_keys([:description, :locked, :run_untagged, :tag_list])
.merge(get_runner_details_from_request)
.merge(maximum_job_timeout_human_readable: params[:maximum_job_timeout])
.merge(maximum_timeout_human_readable: params[:maximum_timeout])
runner =
if runner_registration_token_valid?
......
......@@ -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 :maximum_job_timeout, type: Integer, desc: 'Maximum timeout set when this Runner will handle the job'
optional :maximum_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
......
......@@ -1288,7 +1288,7 @@ describe Ci::Build do
end
context 'when runner sets timeout to bigger value' do
let(:runner2) { create(:ci_runner, maximum_job_timeout: 2000) }
let(:runner2) { create(:ci_runner, maximum_timeout: 2000) }
let(:build) { create(:ci_build, :pending, pipeline: pipeline2, runner: runner2) }
it 'returns project timeout configuration' do
......@@ -1297,11 +1297,11 @@ describe Ci::Build do
end
context 'when runner sets timeout to smaller value' do
let(:runner2) { create(:ci_runner, maximum_job_timeout: 500) }
let(:runner2) { create(:ci_runner, maximum_timeout: 500) }
let(:build) { create(:ci_build, :pending, pipeline: pipeline2, runner: runner2) }
it 'returns project timeout configuration' do
is_expected.to eq(runner2.maximum_job_timeout)
is_expected.to eq(runner2.maximum_timeout)
end
end
end
......@@ -2064,7 +2064,7 @@ describe Ci::Build do
let(:expected_timeout_source) { 'runner_timeout_source' }
before do
runner.maximum_job_timeout = 900
runner.maximum_timeout = 900
runner.save!
end
......@@ -2076,7 +2076,7 @@ describe Ci::Build do
let(:expected_timeout_source) { 'project_timeout_source' }
before do
runner.maximum_job_timeout = 3600
runner.maximum_timeout = 3600
runner.save!
end
......
......@@ -55,8 +55,8 @@ shared_examples 'ChronicDurationAttribute writer' do
end
describe 'ChronicDurationAttribute' do
let(:source_field) {:maximum_job_timeout}
let(:virtual_field) {:maximum_job_timeout_human_readable}
let(:source_field) {:maximum_timeout}
let(:virtual_field) {:maximum_timeout_human_readable}
subject { Ci::Runner.new }
......
......@@ -112,19 +112,19 @@ describe API::Runner do
context 'when maximum job timeout is specified' do
it 'creates runner' do
post api('/runners'), token: registration_token,
maximum_job_timeout: '2h 30m'
maximum_timeout: '2h 30m'
expect(response).to have_gitlab_http_status 201
expect(Ci::Runner.first.maximum_job_timeout).to eq(9000)
expect(Ci::Runner.first.maximum_timeout).to eq(9000)
end
context 'when maximum job timeout is empty' do
it 'creates runner' do
post api('/runners'), token: registration_token,
maximum_job_timeout: ''
maximum_timeout: ''
expect(response).to have_gitlab_http_status 201
expect(Ci::Runner.first.maximum_job_timeout).to be_nil
expect(Ci::Runner.first.maximum_timeout).to be_nil
end
end
end
......@@ -681,7 +681,7 @@ describe API::Runner do
end
context 'when runner specifies lower timeout' do
let(:runner) { create(:ci_runner, maximum_job_timeout: 1000) }
let(:runner) { create(:ci_runner, maximum_timeout: 1000) }
it 'contains info about timeout overridden by runner' do
request_job
......@@ -692,7 +692,7 @@ describe API::Runner do
end
context 'when runner specifies bigger timeout' do
let(:runner) { create(:ci_runner, maximum_job_timeout: 2000) }
let(:runner) { create(:ci_runner, maximum_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['maximum_job_timeout']).to be_nil
expect(json_response['maximum_timeout']).to be_nil
end
end
......@@ -194,7 +194,7 @@ describe API::Runners do
run_untagged: 'false',
locked: 'true',
access_level: 'ref_protected',
maximum_job_timeout: 1234 )
maximum_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.maximum_job_timeout).to eq(1234)
expect(shared_runner.maximum_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