Commit 995e5b52 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'sh-use-shared-state-cluster-pubsub' into 'master'

Use persistent Redis cluster for Workhorse pub/sub notifications

See merge request gitlab-org/gitlab-ce!30990
parents aed07635 583c12ac
...@@ -264,7 +264,7 @@ module Ci ...@@ -264,7 +264,7 @@ module Ci
private private
def cleanup_runner_queue def cleanup_runner_queue
Gitlab::Redis::Queues.with do |redis| Gitlab::Redis::SharedState.with do |redis|
redis.del(runner_queue_key) redis.del(runner_queue_key)
end end
end end
......
---
title: Use persistent Redis cluster for Workhorse pub/sub notifications
merge_request: 30990
author:
type: fixed
...@@ -221,7 +221,7 @@ module Gitlab ...@@ -221,7 +221,7 @@ module Gitlab
end end
def set_key_and_notify(key, value, expire: nil, overwrite: true) 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) result = redis.set(key, value, ex: expire, nx: !overwrite)
if result if result
redis.publish(NOTIFICATION_CHANNEL, "#{key}=#{value}") redis.publish(NOTIFICATION_CHANNEL, "#{key}=#{value}")
......
...@@ -404,6 +404,7 @@ describe Gitlab::Workhorse do ...@@ -404,6 +404,7 @@ describe Gitlab::Workhorse do
end end
it 'set and notify' do it 'set and notify' do
expect(Gitlab::Redis::SharedState).to receive(:with).and_call_original
expect_any_instance_of(::Redis).to receive(:publish) expect_any_instance_of(::Redis).to receive(:publish)
.with(described_class::NOTIFICATION_CHANNEL, "test-key=test-value") .with(described_class::NOTIFICATION_CHANNEL, "test-key=test-value")
......
...@@ -554,7 +554,7 @@ describe Ci::Runner do ...@@ -554,7 +554,7 @@ describe Ci::Runner do
end end
def expect_value_in_queues 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) runner_queue_key = runner.send(:runner_queue_key)
expect(redis.get(runner_queue_key)) expect(redis.get(runner_queue_key))
end end
...@@ -627,7 +627,7 @@ describe Ci::Runner do ...@@ -627,7 +627,7 @@ describe Ci::Runner do
end end
it 'cleans up the queue' do 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 expect(redis.get(queue_key)).to be_nil
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