File tree Expand file tree Collapse file tree 5 files changed +62
-4
lines changed
package/libraries/helpers/new_redis_helper Expand file tree Collapse file tree 5 files changed +62
-4
lines changed Original file line number Diff line number Diff line change @@ -78,8 +78,9 @@ def parse_redis_daemon!
7878 return unless redis_managed?
7979
8080 redis_bind = Gitlab [ 'redis' ] [ 'bind' ] || node [ 'redis' ] [ 'bind' ]
81+ Gitlab [ 'redis' ] [ 'default_host' ] = redis_bind . split ( ' ' ) . first
8182
82- Gitlab [ 'gitlab_rails' ] [ 'redis_host' ] ||= redis_bind
83+ Gitlab [ 'gitlab_rails' ] [ 'redis_host' ] ||= Gitlab [ 'redis' ] [ 'default_host' ]
8384
8485 redis_port_config_key = if Gitlab [ 'redis' ] . key? ( 'port' ) && !Gitlab [ 'redis' ] [ 'port' ] . zero?
8586 # If Redis is specified to run on a non-TLS port
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ def redis_cli_connect_options
5151 end
5252
5353 def redis_cli_tcp_connect_options ( args )
54- args << [ "-h #{ redis [ 'bind ' ] } " ]
54+ args << [ "-h #{ redis [ 'default_host ' ] } " ]
5555 port = redis [ 'port' ] . to_i
5656
5757 if port . zero?
Original file line number Diff line number Diff line change 11redis_dir='<%= node['redis']['dir'] %> '
2- redis_host='<%= node['redis']['bind '] %> '
2+ redis_host='<%= node['redis']['default_host '] %> '
33redis_port='<%= node['redis']['port'] %> '
44redis_tls_port='<%= node['redis']['tls_port'] %> '
55redis_tls_auth_clients='<%= node['redis']['tls_auth_clients'] %> '
Original file line number Diff line number Diff line change 3131 let ( :redis_host ) { '1.2.3.4' }
3232 let ( :redis_port ) { 6370 }
3333
34+ context 'when binding to multiple addresses' do
35+ before do
36+ stub_gitlab_rb (
37+ redis : {
38+ bind : '1.2.3.4 5.6.7.8' ,
39+ port : redis_port
40+ }
41+ )
42+ end
43+
44+ it 'expects redis_host to match first bind value from redis' do
45+ expect ( node [ 'gitlab' ] [ 'gitlab_rails' ] [ 'redis_host' ] ) . to eq '1.2.3.4'
46+
47+ subject . parse_redis_settings
48+ end
49+ end
50+
3451 context 'when not using sentinels' do
3552 before do
3653 stub_gitlab_rb (
Original file line number Diff line number Diff line change 1212 let ( :gitlab_redis_cli_rc ) do
1313 <<-EOF
1414redis_dir='/var/opt/gitlab/redis'
15- redis_host='127.0.0.1 '
15+ redis_host=''
1616redis_port='0'
1717redis_tls_port=''
1818redis_tls_auth_clients='optional'
201201 end
202202 end
203203
204+ context 'with multiple bind addresses' do
205+ let ( :redis_host ) { '1.2.3.4 5.6.7.8' }
206+ let ( :redis_port ) { 6370 }
207+ let ( :master_ip ) { '10.0.0.0' }
208+ let ( :master_port ) { 6371 }
209+
210+ let ( :gitlab_redis_cli_rc ) do
211+ <<-EOF
212+ redis_dir='/var/opt/gitlab/redis'
213+ redis_host='1.2.3.4'
214+ redis_port='6370'
215+ redis_tls_port=''
216+ redis_tls_auth_clients='optional'
217+ redis_tls_cacert_file='/opt/gitlab/embedded/ssl/certs/cacert.pem'
218+ redis_tls_cacert_dir='/opt/gitlab/embedded/ssl/certs/'
219+ redis_tls_cert_file=''
220+ redis_tls_key_file=''
221+ redis_socket=''
222+ EOF
223+ end
224+
225+ before do
226+ stub_gitlab_rb (
227+ redis : {
228+ bind : redis_host ,
229+ port : redis_port ,
230+ master_ip : master_ip ,
231+ master_port : master_port ,
232+ master_password : 'password' ,
233+ master : false
234+ }
235+ )
236+ end
237+
238+ it 'creates gitlab-redis-cli-rc' do
239+ expect ( chef_run ) . to render_file ( '/opt/gitlab/etc/gitlab-redis-cli-rc' )
240+ . with_content ( gitlab_redis_cli_rc )
241+ end
242+ end
243+
204244 context 'with a replica configured' do
205245 let ( :redis_host ) { '1.2.3.4' }
206246 let ( :redis_port ) { 6370 }
You can’t perform that action at this time.
0 commit comments