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 <rmarshall@gitlab.com> Approved-by: Mitchell Nielsen <mnielsen@gitlab.com> Approved-by: Robert Marshall <rmarshall@gitlab.com> Co-authored-by: Stan Hu <stanhu@gmail.com>
This commit is contained in:
commit
32ad31df9c
|
@ -30,6 +30,7 @@ module Redis
|
|||
# The user wants Redis to listen via TCP instead of unix socket.
|
||||
Gitlab['redis']['unixsocket'] = false
|
||||
|
||||
parse_redis_bind_address
|
||||
# Try to discover gitlab_rails redis connection params
|
||||
# based on redis daemon
|
||||
parse_redis_daemon! unless RedisHelper::Checks.has_sentinels?
|
||||
|
@ -74,12 +75,17 @@ module Redis
|
|||
|
||||
private
|
||||
|
||||
def parse_redis_daemon!
|
||||
def parse_redis_bind_address
|
||||
return unless redis_managed?
|
||||
|
||||
redis_bind = Gitlab['redis']['bind'] || node['redis']['bind']
|
||||
Gitlab['redis']['default_host'] = redis_bind.split(' ').first
|
||||
end
|
||||
|
||||
def parse_redis_daemon!
|
||||
return unless redis_managed?
|
||||
|
||||
redis_bind = Gitlab['redis']['bind'] || node['redis']['bind']
|
||||
Gitlab['gitlab_rails']['redis_host'] ||= Gitlab['redis']['default_host']
|
||||
|
||||
redis_port_config_key = if Gitlab['redis'].key?('port') && !Gitlab['redis']['port'].zero?
|
||||
|
|
|
@ -332,6 +332,34 @@ redis_socket=''
|
|||
expect(chef_run).to render_file('/opt/gitlab/etc/gitlab-redis-cli-rc')
|
||||
.with_content(gitlab_redis_cli_rc)
|
||||
end
|
||||
|
||||
context 'with Sentinels configured' do
|
||||
before do
|
||||
stub_gitlab_rb(
|
||||
redis: {
|
||||
bind: redis_host,
|
||||
port: redis_port,
|
||||
ha: true,
|
||||
master_ip: master_ip,
|
||||
master_port: master_port,
|
||||
master_password: 'password',
|
||||
master: false
|
||||
},
|
||||
gitlab_rails: {
|
||||
redis_sentinels: [
|
||||
{ 'host' => '127.0.0.1', 'port' => 2637 }
|
||||
]
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
it_behaves_like 'started down runit service', 'redis'
|
||||
|
||||
it 'creates gitlab-redis-cli-rc' do
|
||||
expect(chef_run).to render_file('/opt/gitlab/etc/gitlab-redis-cli-rc')
|
||||
.with_content(gitlab_redis_cli_rc)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with rename_commands disabled' do
|
||||
|
|
Loading…
Reference in New Issue