Skip to content

Commit 32ad31d

Browse files
Robert Marshallstanhu
andcommitted
Merge branch 'sh-fix-redis-default-host-with-sentinels' into 'master'
Fix reconfigure failure if Redis node has Rails Sentinel config See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7567 Merged-by: Robert Marshall <[email protected]> Approved-by: Mitchell Nielsen <[email protected]> Approved-by: Robert Marshall <[email protected]> Co-authored-by: Stan Hu <[email protected]>
2 parents 1f0bfa5 + 1c579da commit 32ad31d

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

files/gitlab-cookbooks/gitlab/libraries/redis.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def parse_redis_settings
3030
# The user wants Redis to listen via TCP instead of unix socket.
3131
Gitlab['redis']['unixsocket'] = false
3232

33+
parse_redis_bind_address
3334
# Try to discover gitlab_rails redis connection params
3435
# based on redis daemon
3536
parse_redis_daemon! unless RedisHelper::Checks.has_sentinels?
@@ -74,12 +75,17 @@ def redis_managed?
7475

7576
private
7677

77-
def parse_redis_daemon!
78+
def parse_redis_bind_address
7879
return unless redis_managed?
7980

8081
redis_bind = Gitlab['redis']['bind'] || node['redis']['bind']
8182
Gitlab['redis']['default_host'] = redis_bind.split(' ').first
83+
end
84+
85+
def parse_redis_daemon!
86+
return unless redis_managed?
8287

88+
redis_bind = Gitlab['redis']['bind'] || node['redis']['bind']
8389
Gitlab['gitlab_rails']['redis_host'] ||= Gitlab['redis']['default_host']
8490

8591
redis_port_config_key = if Gitlab['redis'].key?('port') && !Gitlab['redis']['port'].zero?

spec/chef/cookbooks/redis/recipes/redis_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,34 @@
332332
expect(chef_run).to render_file('/opt/gitlab/etc/gitlab-redis-cli-rc')
333333
.with_content(gitlab_redis_cli_rc)
334334
end
335+
336+
context 'with Sentinels configured' do
337+
before do
338+
stub_gitlab_rb(
339+
redis: {
340+
bind: redis_host,
341+
port: redis_port,
342+
ha: true,
343+
master_ip: master_ip,
344+
master_port: master_port,
345+
master_password: 'password',
346+
master: false
347+
},
348+
gitlab_rails: {
349+
redis_sentinels: [
350+
{ 'host' => '127.0.0.1', 'port' => 2637 }
351+
]
352+
}
353+
)
354+
end
355+
356+
it_behaves_like 'started down runit service', 'redis'
357+
358+
it 'creates gitlab-redis-cli-rc' do
359+
expect(chef_run).to render_file('/opt/gitlab/etc/gitlab-redis-cli-rc')
360+
.with_content(gitlab_redis_cli_rc)
361+
end
362+
end
335363
end
336364

337365
context 'with rename_commands disabled' do

0 commit comments

Comments
 (0)