redis: Fix missing ssl/auth options for sentinel

This ensures options for redis connections are replicated to sentinel
clients, so that users can enable SSL or authentication in Redis
sentinel while they also enable these in Redis.

Closes-Bug: #2052372
Change-Id: I78727387cf8287554549ff5a99a80f3317cbd59b
This commit is contained in:
Takashi Kajinami 2024-02-04 17:10:00 +09:00
parent 2c0d37c2e5
commit 5a5fc3a7b2
2 changed files with 12 additions and 7 deletions

View File

@ -0,0 +1,7 @@
---
features:
- |
The redis coordination driver now applies the connection arguments to Redis
sentinel. This allows enabling SSL or authentication in Redis Sentinel.
Note that using different SSL certificates or different credentials is not
supported now.

View File

@ -468,17 +468,15 @@ return 1
if 'sentinel' in kwargs:
sentinel_hosts = [
cls._parse_sentinel(fallback)
for fallback in kwargs.get('sentinel_fallback', [])
for fallback in kwargs.pop('sentinel_fallback', [])
]
sentinel_hosts.insert(0, (kwargs['host'], kwargs['port']))
sentinel_name = kwargs.pop('sentinel')
sentinel_server = sentinel.Sentinel(
sentinel_hosts,
socket_timeout=kwargs['socket_timeout'])
sentinel_name = kwargs['sentinel']
del kwargs['sentinel']
if 'sentinel_fallback' in kwargs:
del kwargs['sentinel_fallback']
master_client = sentinel_server.master_for(sentinel_name, **kwargs)
sentinel_kwargs=kwargs,
**kwargs)
master_client = sentinel_server.master_for(sentinel_name)
# The master_client is a redis.Redis using a
# Sentinel managed connection pool.
return master_client