summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2018-02-21 01:21:59 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2018-03-28 13:55:46 +0200
commitd633bc8134fe472137fb668c1eb78de45dc9bb57 (patch)
treed50c6d3a4bceb0bda5a20b05820bf9efb37b5b40
parenta4ea9a93db98461479dcb8e1d7b8425a77018f1e (diff)
downloadgitlab-ce-d633bc8134fe472137fb668c1eb78de45dc9bb57.tar.gz
Rename job_upper_timeout to maximum_job_timeout
-rw-r--r--app/models/ci/build.rb4
-rw-r--r--app/models/ci/runner.rb8
-rw-r--r--app/views/admin/runners/_runner.html.haml4
-rw-r--r--app/views/admin/runners/index.html.haml2
-rw-r--r--app/views/projects/runners/_form.html.haml6
-rw-r--r--app/views/projects/runners/_runner.html.haml4
-rw-r--r--app/views/projects/runners/show.html.haml4
-rw-r--r--db/migrate/20180219153455_add_job_upper_timeout_to_ci_runners.rb13
-rw-r--r--db/migrate/20180219153455_add_maximum_job_timeout_to_ci_runners.rb13
-rw-r--r--db/schema.rb2
-rw-r--r--doc/api/runners.md6
-rw-r--r--lib/api/entities.rb2
-rw-r--r--lib/api/runner.rb4
-rw-r--r--lib/api/runners.rb2
-rw-r--r--spec/models/ci/build_spec.rb6
-rw-r--r--spec/models/ci/runner_spec.rb12
-rw-r--r--spec/requests/api/runner_spec.rb10
-rw-r--r--spec/requests/api/runners_spec.rb6
18 files changed, 54 insertions, 54 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index e15c4bc6ceb..61a0ef08dde 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -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
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index cf91ed3c9dc..3d83e00ccfe 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 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
diff --git a/app/views/admin/runners/_runner.html.haml b/app/views/admin/runners/_runner.html.haml
index 14aee600809..5f0fb5079d9 100644
--- a/app/views/admin/runners/_runner.html.haml
+++ b/app/views/admin/runners/_runner.html.haml
@@ -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
diff --git a/app/views/admin/runners/index.html.haml b/app/views/admin/runners/index.html.haml
index 95fd7fe7ebe..a0c7d8f5fa9 100644
--- a/app/views/admin/runners/index.html.haml
+++ b/app/views/admin/runners/index.html.haml
@@ -61,7 +61,7 @@
%th Description
%th Version
%th IP Address
- %th Timeout
+ %th Maximum timeout
%th Projects
%th Jobs
%th Tags
diff --git a/app/views/projects/runners/_form.html.haml b/app/views/projects/runners/_form.html.haml
index 4fb4323dab4..8fb8e6e0ebf 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 :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
diff --git a/app/views/projects/runners/_runner.html.haml b/app/views/projects/runners/_runner.html.haml
index e3107fecfad..f7c41fe44c0 100644
--- a/app/views/projects/runners/_runner.html.haml
+++ b/app/views/projects/runners/_runner.html.haml
@@ -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|
diff --git a/app/views/projects/runners/show.html.haml b/app/views/projects/runners/show.html.haml
index e0223eeb729..0d39236680c 100644
--- a/app/views/projects/runners/show.html.haml
+++ b/app/views/projects/runners/show.html.haml
@@ -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
diff --git a/db/migrate/20180219153455_add_job_upper_timeout_to_ci_runners.rb b/db/migrate/20180219153455_add_job_upper_timeout_to_ci_runners.rb
deleted file mode 100644
index 418ec7ac1d9..00000000000
--- a/db/migrate/20180219153455_add_job_upper_timeout_to_ci_runners.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class AddJobUpperTimeoutToCiRunners < ActiveRecord::Migration
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
-
- def up
- add_column :ci_runners, :job_upper_timeout, :integer
- end
-
- def down
- remove_column :ci_runners, :job_upper_timeout
- end
-end
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
new file mode 100644
index 00000000000..5656970ede9
--- /dev/null
+++ b/db/migrate/20180219153455_add_maximum_job_timeout_to_ci_runners.rb
@@ -0,0 +1,13 @@
+class AddMaximumJobTimeoutToCiRunners < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ add_column :ci_runners, :maximum_job_timeout, :integer
+ end
+
+ def down
+ remove_column :ci_runners, :maximum_job_timeout
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 413f42df40b..806e829dcbd 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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
diff --git a/doc/api/runners.md b/doc/api/runners.md
index 4c6fc029a66..348fd499af2 100644
--- a/doc/api/runners.md
+++ b/doc/api/runners.md
@@ -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
}
```
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index becd4f22a03..bb18fa00dc6 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 :job_upper_timeout
+ expose :maximum_job_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 14dd3b81dd0..3a26155be6d 100644
--- a/lib/api/runner.rb
+++ b/lib/api/runner.rb
@@ -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 =
diff --git a/lib/api/runners.rb b/lib/api/runners.rb
index bc91b7cfd54..b3037235353 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 :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
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index d13421a107f..115106548f0 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -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
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index 80d7cd92fdb..5b5fa7fac01 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -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
diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb
index 3eb0e88d095..a6a4f510406 100644
--- a/spec/requests/api/runner_spec.rb
+++ b/spec/requests/api/runner_spec.rb
@@ -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
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb
index 0444880a300..836b22f5657 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['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