Skip to content

Commit

Permalink
allow redis config to not use ssl
Browse files Browse the repository at this point in the history
  • Loading branch information
bgunnar5 committed Sep 25, 2024
1 parent c7adb96 commit 608e00e
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions merlin/managers/redis_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ def get_redis_connection(self) -> redis.Redis:
port = CONFIG.results_backend.port if hasattr(CONFIG.results_backend, "port") else None
results_db_num = CONFIG.results_backend.db_num if hasattr(CONFIG.results_backend, "db_num") else None
username = CONFIG.results_backend.username if hasattr(CONFIG.results_backend, "username") else None
has_ssl = hasattr(CONFIG.results_backend, "cert_reqs")
ssl_cert_reqs = CONFIG.results_backend.cert_reqs if has_ssl else "required"

password = None
if password_file is not None:
Expand All @@ -82,13 +80,21 @@ def get_redis_connection(self) -> redis.Redis:
if hasattr(CONFIG.results_backend, "password"):
password = CONFIG.results_backend.password

return redis.Redis(
host=server,
port=port,
db=results_db_num + self.db_num, # Increment db_num to avoid conflicts
username=username,
password=password,
decode_responses=True,
ssl=has_ssl,
ssl_cert_reqs=ssl_cert_reqs,
)
# Base configuration for Redis connection (this does not have ssl)
redis_config = {
"host": server,
"port": port,
"db": results_db_num + self.db_num, # Increment db_num to avoid conflicts
"username": username,
"password": password,
"decode_responses": True,
}

# Add ssl settings if necessary
if CONFIG.results_backend.name == "rediss":
redis_config.update({
"ssl": True,
"ssl_cert_reqs": getattr(CONFIG.results_backend, "cert_reqs", "required"),
})

return redis.Redis(**redis_config)

0 comments on commit 608e00e

Please sign in to comment.