Optimised paused runners to not re-query every 3s
We have long polling mechanism which is not being used by paused runners. This makes the paused runner to generate a request every 3s, where it could be fired only every 1h.
This commit is contained in:
parent
7b1eb2a669
commit
cc48d67ca5
3 changed files with 13 additions and 2 deletions
5
changelogs/unreleased/optimise-paused-runners.yml
Normal file
5
changelogs/unreleased/optimise-paused-runners.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Optimise paused runners to reduce amount of used requests
|
||||||
|
merge_request:
|
||||||
|
author:
|
||||||
|
type: performance
|
|
@ -84,7 +84,11 @@ module API
|
||||||
end
|
end
|
||||||
post '/request' do
|
post '/request' do
|
||||||
authenticate_runner!
|
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])
|
if current_runner.runner_queue_value_latest?(params[:last_update])
|
||||||
header 'X-GitLab-Last-Update', params[:last_update]
|
header 'X-GitLab-Last-Update', params[:last_update]
|
||||||
|
|
|
@ -351,11 +351,13 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
|
||||||
context 'when valid token is provided' do
|
context 'when valid token is provided' do
|
||||||
context 'when Runner is not active' do
|
context 'when Runner is not active' do
|
||||||
let(:runner) { create(:ci_runner, :inactive) }
|
let(:runner) { create(:ci_runner, :inactive) }
|
||||||
|
let(:update_value) { runner.ensure_runner_queue_value }
|
||||||
|
|
||||||
it 'returns 204 error' do
|
it 'returns 204 error' do
|
||||||
request_job
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue