diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-17 18:05:56 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-06-17 18:05:56 +0000 |
commit | 1e22513afde6fb1d3a604e88e1a8f944b07dd858 (patch) | |
tree | 01c5eb4f4c3e637b0ee2ff345fae7567fa1804b7 | |
parent | 7b1eb2a669ad2a44dbe89d7d289d72870cbd74e7 (diff) | |
parent | cc48d67ca57ac99e5c61b422a56d96a1643a7de8 (diff) | |
download | gitlab-ce-1e22513afde6fb1d3a604e88e1a8f944b07dd858.tar.gz |
Merge branch 'optimise-paused-runners' into 'master'
Optimise paused runners
See merge request gitlab-org/gitlab-ce!19946
-rw-r--r-- | changelogs/unreleased/optimise-paused-runners.yml | 5 | ||||
-rw-r--r-- | lib/api/runner.rb | 6 | ||||
-rw-r--r-- | spec/requests/api/runner_spec.rb | 4 |
3 files changed, 13 insertions, 2 deletions
diff --git a/changelogs/unreleased/optimise-paused-runners.yml b/changelogs/unreleased/optimise-paused-runners.yml new file mode 100644 index 00000000000..13097e507d3 --- /dev/null +++ b/changelogs/unreleased/optimise-paused-runners.yml @@ -0,0 +1,5 @@ +--- +title: Optimise paused runners to reduce amount of used requests +merge_request: +author: +type: performance diff --git a/lib/api/runner.rb b/lib/api/runner.rb index dc102259ca8..96a02914faa 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -84,7 +84,11 @@ module API end post '/request' do authenticate_runner! - no_content! unless current_runner.active? + + unless current_runner.active? + header 'X-GitLab-Last-Update', current_runner.ensure_runner_queue_value + break no_content! + end if current_runner.runner_queue_value_latest?(params[:last_update]) header 'X-GitLab-Last-Update', params[:last_update] diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 16e6f19773f..e7639599874 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -351,11 +351,13 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when valid token is provided' do context 'when Runner is not active' do let(:runner) { create(:ci_runner, :inactive) } + let(:update_value) { runner.ensure_runner_queue_value } it 'returns 204 error' do request_job - expect(response).to have_gitlab_http_status 204 + expect(response).to have_gitlab_http_status(204) + expect(response.header['X-GitLab-Last-Update']).to eq(update_value) end end |