Skip to content

Commit 3577087

Browse files
committed
Make get-redis-master command work when running behind SSL
Changelog: fixed Signed-off-by: Balasankar "Balu" C <[email protected]>
1 parent 987ae51 commit 3577087

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

files/gitlab-ctl-commands/get_redis_master.rb

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# changed to `gitlab_rails`. Hence we try both.
2424
redis_sentinels = node_attributes.dig('gitlab', 'gitlab_rails', 'redis_sentinels') || node_attributes.dig('gitlab', 'gitlab-rails', 'redis_sentinels')
2525
redis_master_name = node_attributes['redis']['master_name']
26+
redis_ssl = node_attributes.dig('gitlab', 'gitlab_rails', 'redis_ssl')
2627

2728
master_host = nil
2829
master_port = nil
@@ -42,7 +43,25 @@
4243
redis_sentinels.each do |sentinel|
4344
host = sentinel['host']
4445
port = sentinel['port']
45-
command = "/opt/gitlab/embedded/bin/redis-cli -h #{host} -p #{port} SENTINEL get-master-addr-by-name #{redis_master_name}"
46+
47+
if redis_ssl
48+
tls_arg = '--tls'
49+
50+
tls_settings = {
51+
cacert: node_attributes.dig('gitlab', 'gitlab_rails', 'redis_tls_ca_cert_file'),
52+
cacertdir: node_attributes.dig('gitlab', 'gitlab_rails', 'redis_tls_ca_cert_dir'),
53+
cert: node_attributes.dig('gitlab', 'gitlab_rails', 'redis_tls_client_cert_file'),
54+
key: node_attributes.dig('gitlab', 'gitlab_rails', 'redis_tls_client_key_file')
55+
}
56+
57+
tls_settings.each do |key, value|
58+
tls_arg += " --#{key} #{value}" if value
59+
end
60+
else
61+
tls_arg = ''
62+
end
63+
64+
command = "/opt/gitlab/embedded/bin/redis-cli -h #{host} -p #{port} #{tls_arg} SENTINEL get-master-addr-by-name #{redis_master_name}"
4665
output = GitlabCtl::Util.get_command_output(command).strip
4766
master_host, master_port = output.split("\n")
4867
break

0 commit comments

Comments
 (0)