From 5a5fc3a7b24b60df498767a083df62d3579c95dd Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 4 Feb 2024 17:10:00 +0900 Subject: [PATCH] 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 --- .../sentinel-ssl-and-auth-5cccced6685099b9.yaml | 7 +++++++ tooz/drivers/redis.py | 12 +++++------- 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/sentinel-ssl-and-auth-5cccced6685099b9.yaml diff --git a/releasenotes/notes/sentinel-ssl-and-auth-5cccced6685099b9.yaml b/releasenotes/notes/sentinel-ssl-and-auth-5cccced6685099b9.yaml new file mode 100644 index 00000000..894ed493 --- /dev/null +++ b/releasenotes/notes/sentinel-ssl-and-auth-5cccced6685099b9.yaml @@ -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. diff --git a/tooz/drivers/redis.py b/tooz/drivers/redis.py index 812706ab..401fedb9 100644 --- a/tooz/drivers/redis.py +++ b/tooz/drivers/redis.py @@ -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