diff options
-rw-r--r-- | app/models/ci/build_metadata.rb | 2 | ||||
-rw-r--r-- | app/models/ci/runner.rb | 4 | ||||
-rw-r--r-- | app/views/projects/runners/_form.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/runners/show.html.haml | 2 | ||||
-rw-r--r-- | db/migrate/20180219153455_add_maximum_job_timeout_to_ci_runners.rb | 9 | ||||
-rw-r--r-- | db/migrate/20180219153455_add_maximum_timeout_to_ci_runners.rb | 9 | ||||
-rw-r--r-- | db/schema.rb | 2 | ||||
-rw-r--r-- | doc/api/runners.md | 6 | ||||
-rw-r--r-- | lib/api/entities.rb | 2 | ||||
-rw-r--r-- | lib/api/runner.rb | 4 | ||||
-rw-r--r-- | lib/api/runners.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 10 | ||||
-rw-r--r-- | spec/models/concerns/chronic_duration_attribute_spec.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/runner_spec.rb | 12 | ||||
-rw-r--r-- | spec/requests/api/runners_spec.rb | 6 |
15 files changed, 39 insertions, 39 deletions
diff --git a/app/models/ci/build_metadata.rb b/app/models/ci/build_metadata.rb index 9043bed86bf..89fee37b1b6 100644 --- a/app/models/ci/build_metadata.rb +++ b/app/models/ci/build_metadata.rb @@ -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 diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 413607e0eff..62cc636db22 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -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. # diff --git a/app/views/projects/runners/_form.html.haml b/app/views/projects/runners/_form.html.haml index 7e9435e0110..6a681736b6f 100644 --- a/app/views/projects/runners/_form.html.haml +++ b/app/views/projects/runners/_form.html.haml @@ -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 diff --git a/app/views/projects/runners/show.html.haml b/app/views/projects/runners/show.html.haml index 67084e3d66a..f33e7e25b68 100644 --- a/app/views/projects/runners/show.html.haml +++ b/app/views/projects/runners/show.html.haml @@ -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 diff --git a/db/migrate/20180219153455_add_maximum_job_timeout_to_ci_runners.rb b/db/migrate/20180219153455_add_maximum_job_timeout_to_ci_runners.rb deleted file mode 100644 index 1ad7bb86e72..00000000000 --- a/db/migrate/20180219153455_add_maximum_job_timeout_to_ci_runners.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddMaximumJobTimeoutToCiRunners < ActiveRecord::Migration - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - def change - add_column :ci_runners, :maximum_job_timeout, :integer - end -end diff --git a/db/migrate/20180219153455_add_maximum_timeout_to_ci_runners.rb b/db/migrate/20180219153455_add_maximum_timeout_to_ci_runners.rb new file mode 100644 index 00000000000..072e696a43e --- /dev/null +++ b/db/migrate/20180219153455_add_maximum_timeout_to_ci_runners.rb @@ -0,0 +1,9 @@ +class AddMaximumTimeoutToCiRunners < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :ci_runners, :maximum_timeout, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 920d71e0110..a2967409703 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 diff --git a/doc/api/runners.md b/doc/api/runners.md index 348fd499af2..f384ac57bfe 100644 --- a/doc/api/runners.md +++ b/doc/api/runners.md @@ -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 } ``` diff --git a/lib/api/entities.rb b/lib/api/entities.rb index bb18fa00dc6..324e14f5654 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -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 diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 73d5993701c..95f57e6402d 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -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? diff --git a/lib/api/runners.rb b/lib/api/runners.rb index b3037235353..5f2a9567605 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -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 diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 670803a0883..abb2d0b5ecb 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -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 diff --git a/spec/models/concerns/chronic_duration_attribute_spec.rb b/spec/models/concerns/chronic_duration_attribute_spec.rb index b25475d4fdb..c991d12a5fc 100644 --- a/spec/models/concerns/chronic_duration_attribute_spec.rb +++ b/spec/models/concerns/chronic_duration_attribute_spec.rb @@ -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 } diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 0ca7ba7154e..6676ceaab66 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -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 diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index 836b22f5657..247e8795ed4 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -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 |