Commit ff75bd04 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-shared-runners-queue-update' into 'master'

Fix shared runners queue update

See merge request !8663
parents d8690a05 a5ab418c
...@@ -126,9 +126,11 @@ module Ci ...@@ -126,9 +126,11 @@ module Ci
end end
def tick_runner_queue def tick_runner_queue
new_update = SecureRandom.hex SecureRandom.hex.tap do |new_update|
Gitlab::Redis.with { |redis| redis.set(runner_queue_key, new_update, ex: RUNNER_QUEUE_EXPIRY_TIME) } Gitlab::Redis.with do |redis|
new_update redis.set(runner_queue_key, new_update, ex: RUNNER_QUEUE_EXPIRY_TIME)
end
end
end end
def ensure_runner_queue_value def ensure_runner_queue_value
......
...@@ -6,6 +6,14 @@ module Ci ...@@ -6,6 +6,14 @@ module Ci
runner.tick_runner_queue runner.tick_runner_queue
end end
end end
return unless build.project.shared_runners_enabled?
Ci::Runner.shared.each do |runner|
if runner.can_pick?(build)
runner.tick_runner_queue
end
end
end end
end end
end end
require 'spec_helper'
describe Ci::UpdateBuildQueueService, :services do
let(:project) { create(:project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:pipeline) { create(:ci_pipeline, project: project) }
context 'when updating specific runners' do
let(:runner) { create(:ci_runner) }
context 'when there are runner that can pick build' do
before { build.project.runners << runner }
it 'ticks runner queue value' do
expect { subject.execute(build) }
.to change { runner.ensure_runner_queue_value }
end
end
context 'when there are no runners that can pick build' do
it 'does not tick runner queue value' do
expect { subject.execute(build) }
.not_to change { runner.ensure_runner_queue_value }
end
end
end
context 'when updating shared runners' do
let(:runner) { create(:ci_runner, :shared) }
context 'when there are runner that can pick build' do
it 'ticks runner queue value' do
expect { subject.execute(build) }
.to change { runner.ensure_runner_queue_value }
end
end
context 'when there are no runners that can pick build' do
before { build.tag_list = [:docker] }
it 'does not tick runner queue value' do
expect { subject.execute(build) }
.not_to change { runner.ensure_runner_queue_value }
end
end
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