feat(redis): add Redis Sentinel support for HA cache discovery#2618
feat(redis): add Redis Sentinel support for HA cache discovery#2618ex0a wants to merge 5 commits intomozilla:mainfrom
Conversation
|
sorry, it conflicts |
|
What would you suggest? I'm using this personally but thought it might help someone else |
|
Hi @ex0a , You should rebase your changes to the latest Then you need to push your changes to your branch. That's should be fine! |
|
CC @Xuanwo IMO, we should implement the Redis Sentinel support as a part of the OpenDAL. And just use it here. Possibly, it's already done. |
d088922 to
5288c2d
Compare
|
Thanks for the review! I've pushed updates addressing both points: |
5288c2d to
b477146
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2618 +/- ##
==========================================
- Coverage 73.36% 73.17% -0.20%
==========================================
Files 68 68
Lines 37337 37442 +105
==========================================
+ Hits 27393 27397 +4
- Misses 9944 10045 +101 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
please fix the jobs |
Merging this PR will not alter performance
Comparing Footnotes
|
|
Hi @sylvestre — CodSpeed results came in: +3.56% improvement on |
c16ad8b to
51c20d1
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds Redis Sentinel support for high-availability cache discovery in sccache. When an endpoint config value starts with redis-sentinel://, the code routes to a new build_sentinel() function that manually queries sentinel nodes using the SENTINEL GET-MASTER-ADDR-BY-NAME command, discovers the current master's address, then builds a normal Redis Operator pointed at that master.
Changes:
build_sentinel()added toRedisCacheto parse sentinel URLs, query sentinels, and discover the master addresscache.rsupdated to detectredis-sentinel://endpoint URLs and route them to the sentinel builderCargo.tomlupdated to add therediscrate (for direct sentinel querying) andtracingas direct dependencies
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/cache/redis.rs |
Adds build_sentinel() which manually parses sentinel URLs and queries sentinels for master address |
src/cache/cache.rs |
Routes redis-sentinel:// endpoint URLs to the new sentinel handler |
Cargo.toml |
Adds redis crate (optional, feature-gated) and tracing (non-optional) as direct dependencies |
Cargo.lock |
Reflects resolved dependency versions including redis 0.32.7 and updated tracing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
51c20d1 to
fcfe986
Compare
|
Rebased onto latest main and addressed all four Copilot findings:
clippy, rustfmt, and taplo all pass clean. |
- Add build_sentinel() function to discover Redis master via Sentinel - Parse redis-sentinel://host:port,host2:port2/master_name URLs - Query sentinels with SENTINEL GET-MASTER-ADDR-BY-NAME - Add comprehensive logging for debugging discovery issues - Support password auth and optional DB selection - Route sentinel URLs from endpoint config path in cache.rs - Warn when username/password/db are provided with sentinel URLs - Fix redis feature gating with dep:redis
- Fix build_from_url -> build_sentinel call so sentinel discovery is
actually used (cache.rs)
- Use rsplit_once('@') for password parsing to handle '@' in passwords
(redis.rs)
- Remove unused `sentinel` feature flag from redis crate (Cargo.toml)
- Remove unnecessary `tracing` dependency (Cargo.toml)
Avoid set-then-unwrap pattern by binding the formatted message to a local before moving it into last_error.
- Extract parse_sentinel_url() for testable URL parsing - Add SentinelUrl struct for parsed components - Add 9 unit tests: simple, multi-node, password, password-with-@, db selection, full URL, missing master, invalid db, no port - Fix remaining set-then-unwrap in sentinel query/response error paths - Use splitn(3, '/') to prevent over-splitting on db segment - Add doc comments to build_sentinel with URL format spec
f37f161 to
5d433c2
Compare
Adds Redis Sentinel support so sccache can discover the current master from a sentinel cluster instead of hardcoding a single Redis endpoint.
When
endpointstarts withredis-sentinel://, sccache queries each sentinel node withSENTINEL GET-MASTER-ADDR-BY-NAME, connects to the discovered master, and builds the opendal operator against it.URL format:
redis-sentinel://[:password@]host1[:port1][,host2[:port2],...]/master_name[/db]Example config:
username,password, anddbconfig fields are ignored for sentinel URLs (embed credentials in the URL). A warning is logged if they're set.URL parsing is extracted into
parse_sentinel_url()with unit tests covering multi-node, password with@, db selection, and error cases.