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!
78
78
return unless redis_managed?
79
79
80
80
redis_bind = Gitlab [ 'redis' ] [ 'bind' ] || node [ 'redis' ] [ 'bind' ]
81
+ Gitlab [ 'redis' ] [ 'default_host' ] = redis_bind . split ( ' ' ) . first
81
82
82
- Gitlab [ 'gitlab_rails' ] [ 'redis_host' ] ||= redis_bind
83
+ Gitlab [ 'gitlab_rails' ] [ 'redis_host' ] ||= Gitlab [ 'redis' ] [ 'default_host' ]
83
84
84
85
redis_port_config_key = if Gitlab [ 'redis' ] . key? ( 'port' ) && !Gitlab [ 'redis' ] [ 'port' ] . zero?
85
86
# 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
51
51
end
52
52
53
53
def redis_cli_tcp_connect_options ( args )
54
- args << [ "-h #{ redis [ 'bind ' ] } " ]
54
+ args << [ "-h #{ redis [ 'default_host ' ] } " ]
55
55
port = redis [ 'port' ] . to_i
56
56
57
57
if port . zero?
Original file line number Diff line number Diff line change 1
1
redis_dir='<%= node['redis']['dir'] %> '
2
- redis_host='<%= node['redis']['bind '] %> '
2
+ redis_host='<%= node['redis']['default_host '] %> '
3
3
redis_port='<%= node['redis']['port'] %> '
4
4
redis_tls_port='<%= node['redis']['tls_port'] %> '
5
5
redis_tls_auth_clients='<%= node['redis']['tls_auth_clients'] %> '
Original file line number Diff line number Diff line change 31
31
let ( :redis_host ) { '1.2.3.4' }
32
32
let ( :redis_port ) { 6370 }
33
33
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
+
34
51
context 'when not using sentinels' do
35
52
before do
36
53
stub_gitlab_rb (
Original file line number Diff line number Diff line change 12
12
let ( :gitlab_redis_cli_rc ) do
13
13
<<-EOF
14
14
redis_dir='/var/opt/gitlab/redis'
15
- redis_host='127.0.0.1 '
15
+ redis_host=''
16
16
redis_port='0'
17
17
redis_tls_port=''
18
18
redis_tls_auth_clients='optional'
201
201
end
202
202
end
203
203
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
+
204
244
context 'with a replica configured' do
205
245
let ( :redis_host ) { '1.2.3.4' }
206
246
let ( :redis_port ) { 6370 }
You can’t perform that action at this time.
0 commit comments