ENG-3194 - Ensure Redis connection URL is correct when configured to use a cluster + SSL #7811
ENG-3194 - Ensure Redis connection URL is correct when configured to use a cluster + SSL #7811
Conversation
…enerated is correct (i.e rediss+cluster://.../<ssl parameters>)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
There was a problem hiding this comment.
Code Review
The fix is correct and well-scoped. get_cluster_connection_url() was returning a bare redis+cluster:// or rediss+cluster:// URL with no query parameters even when SSL was configured, which would silently drop certificate validation settings. The new code mirrors the existing SSL param-building logic from the non-cluster URL builder, which is the right approach.
No blockers. Two minor observations are left as inline comments:
-
ssl_cert_reqs(andssl_ca_certs) are pre-encoded before being passed tourlencode, which technically double-encodes them — though in practice this is invisible since the expected values contain no special characters. This is a pre-existing pattern, not introduced here, and is worth a follow-up cleanup. -
Missing test coverage for (a) cluster mode without SSL, and (b) cluster + SSL + auth credentials together. Neither is a correctness concern for the current change, but they'd improve regression safety.
The changelog is noted as unchecked in the PR template — please add an entry before merge.
|
|
||
| params_str = "" | ||
| if self.ssl: | ||
| params = {"ssl_cert_reqs": quote_plus(self.ssl_cert_reqs or "none")} |
There was a problem hiding this comment.
Minor: the value for ssl_cert_reqs is pre-encoded with quote_plus before being handed to urlencode(..., quote_via=quote), which means it gets encoded twice. For the expected values ("none", "required", "optional") this has no visible effect since they contain no special characters — but it's an inconsistency worth noting. The ssl_ca_certs value below is pre-encoded with quote similarly. Since this mirrors the existing pattern in the non-cluster URL builder (lines 310–314), I'd suggest tracking this as a follow-up cleanup rather than a blocker. Ideally, raw values would be passed and urlencode would handle all encoding uniformly.
| assert ( | ||
| redis_settings.get_cluster_connection_url() | ||
| == "rediss+cluster://:testpassword@redis:6379/0?ssl_cert_reqs=required&ssl_check_hostname=False" | ||
| ) |
There was a problem hiding this comment.
The three new tests cover the SSL-on path well. Two small gaps worth considering:
-
No test for the non-SSL cluster path.
get_cluster_connection_url()withssl=False(the original behavior) is not tested. Adding a simple case likeRedisSettings(cluster_enabled=True)→"redis+cluster://:testpassword@redis:6379/0"would confirm the non-params branch still works and prevent regressions. -
No test combining cluster + SSL + auth credentials. The non-cluster TLS tests don't cover auth either, but since the cluster implementation explicitly handles
self.password/self.user, a test likeRedisSettings(cluster_enabled=True, ssl=True, password="secret", user="admin")would give more confidence the auth prefix and SSL params are composed correctly in the same URL.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7811 +/- ##
==========================================
+ Coverage 85.01% 85.03% +0.01%
==========================================
Files 614 614
Lines 40094 40101 +7
Branches 4671 4673 +2
==========================================
+ Hits 34087 34098 +11
+ Misses 4965 4959 -6
- Partials 1042 1044 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Ticket ENG-3194
Description Of Changes
Ensures that when SSL and cluster mode are enabled that the query parameters in the generated URL are correct.
Code Changes
Steps to Confirm
N/A - no manual tests required
Pre-Merge Checklist
CHANGELOG.mdupdatedmaindowngrade()migration is correct and works