Use persistent Redis cluster for Workhorse pub/sub notifications

Previously, in Omnibus, Workhorse expected to listen via the Redis
shared state cluster for the `workhorse:notifications` publish/subscribe
channel, but the Rails code was using the Sidekiq queue cluster for
this. To fix this inconsistency, we make the Rails code use the
persistent cluster, since we don't want Workhorse to be looking at
anything Sidekiq-related.
This commit is contained in:
Stan Hu 2019-07-21 23:00:37 -07:00
parent 3cc5535c0c
commit 583c12acf4
5 changed files with 10 additions and 4 deletions

View File

@ -264,7 +264,7 @@ module Ci
private
def cleanup_runner_queue
Gitlab::Redis::Queues.with do |redis|
Gitlab::Redis::SharedState.with do |redis|
redis.del(runner_queue_key)
end
end

View File

@ -0,0 +1,5 @@
---
title: Use persistent Redis cluster for Workhorse pub/sub notifications
merge_request: 30990
author:
type: fixed

View File

@ -221,7 +221,7 @@ module Gitlab
end
def set_key_and_notify(key, value, expire: nil, overwrite: true)
Gitlab::Redis::Queues.with do |redis|
Gitlab::Redis::SharedState.with do |redis|
result = redis.set(key, value, ex: expire, nx: !overwrite)
if result
redis.publish(NOTIFICATION_CHANNEL, "#{key}=#{value}")

View File

@ -404,6 +404,7 @@ describe Gitlab::Workhorse do
end
it 'set and notify' do
expect(Gitlab::Redis::SharedState).to receive(:with).and_call_original
expect_any_instance_of(::Redis).to receive(:publish)
.with(described_class::NOTIFICATION_CHANNEL, "test-key=test-value")

View File

@ -554,7 +554,7 @@ describe Ci::Runner do
end
def expect_value_in_queues
Gitlab::Redis::Queues.with do |redis|
Gitlab::Redis::SharedState.with do |redis|
runner_queue_key = runner.send(:runner_queue_key)
expect(redis.get(runner_queue_key))
end
@ -627,7 +627,7 @@ describe Ci::Runner do
end
it 'cleans up the queue' do
Gitlab::Redis::Queues.with do |redis|
Gitlab::Redis::SharedState.with do |redis|
expect(redis.get(queue_key)).to be_nil
end
end