Repository navigation
[MOD-15867] coord: search.CLUSTERSET AUTH <pw> short-form using module API - #9779
Conversation
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
search.CLUSTERSET AUTH <pw> short-form using module API
…std::string::copy for safer string handling
- cluster_topology.c: take RedisModule_ClusterGetSlotRangesByNodeId result as pointer-to-const (S5350). - redismock.cpp: switch the cluster-mock locks from std::lock_guard<std::mutex> to std::scoped_lock (S5997, S6012); use const references in iteration loops (S5350); mark unused ctx/master_id parameters as unnamed (S1172). - test_cpp_cluster_topology.cpp: pass addNode's slots by const reference (S1238); use nullptr instead of NULL (S4962). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The "?" sentinel is a CLUSTER SHARDS reply convention for an unknown endpoint; the RedisModule_GetClusterNodeInfo API doesn't return it. Drop the check and the NODE_D fixture that exercised it. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Rename RedisModule_ClusterGetSlotRangesByNodeId → RedisModule_GetClusterNodeSlotRanges to match the symbol name in the upstream Redis PR that adds this API (redis/redis#14953). Move the redismodule.h declaration and REDISMODULE_GET_API call to the same position upstream places them (next to GetClusterNodeInfo) so the file stays close to a straight diff against upstream once the PR lands. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
search.CLUSTERSET AUTH <pw> short-form using module APIsearch.CLUSTERSET AUTH <pw> short-form using module API
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60d75287d2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9779 +/- ##
==========================================
+ Coverage 81.35% 81.69% +0.34%
==========================================
Files 511 508 -3
Lines 69233 68841 -392
Branches 25689 25220 -469
==========================================
- Hits 56324 56241 -83
+ Misses 12665 12359 -306
+ Partials 244 241 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1231c7d. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1231c7d668
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 8.4
git worktree add -d .worktree/backport-9779-to-8.4 origin/8.4
cd .worktree/backport-9779-to-8.4
git switch --create backport-9779-to-8.4
git cherry-pick -x 9a6b9b1ea8f52e2f752177c05e06863c4d1e32c0 |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 8.6
git worktree add -d .worktree/backport-9779-to-8.6 origin/8.6
cd .worktree/backport-9779-to-8.6
git switch --create backport-9779-to-8.6
git cherry-pick -x 9a6b9b1ea8f52e2f752177c05e06863c4d1e32c0 |
|
Successfully created backport PR for |
|
Successfully created backport PR for |
…ule API (#9779) * Implement MRClusterTopology_FromAPI function to retrieve cluster topology from module API * Add parse_topology_short_form function to handle short form topology parsing * Add tests and new required mock API * Refactor RMCK_GetClusterNodesList and RMCK_GetClusterNodeInfo to use std::string::copy for safer string handling * Address SonarCloud lints in new short-form code - cluster_topology.c: take RedisModule_ClusterGetSlotRangesByNodeId result as pointer-to-const (S5350). - redismock.cpp: switch the cluster-mock locks from std::lock_guard<std::mutex> to std::scoped_lock (S5997, S6012); use const references in iteration loops (S5350); mark unused ctx/master_id parameters as unnamed (S1172). - test_cpp_cluster_topology.cpp: pass addNode's slots by const reference (S1238); use nullptr instead of NULL (S4962). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Drop unreachable ip[0] == '?' check in MRClusterTopology_FromAPI The "?" sentinel is a CLUSTER SHARDS reply convention for an unknown endpoint; the RedisModule_GetClusterNodeInfo API doesn't return it. Drop the check and the NODE_D fixture that exercised it. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Align cluster slot-ranges API name with upstream Redis PR #14953 Rename RedisModule_ClusterGetSlotRangesByNodeId → RedisModule_GetClusterNodeSlotRanges to match the symbol name in the upstream Redis PR that adds this API (redis/redis#14953). Move the redismodule.h declaration and REDISMODULE_GET_API call to the same position upstream places them (next to GetClusterNodeInfo) so the file stays close to a straight diff against upstream once the PR lands. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Manage cluster-API allocations explicitly instead of via auto-memory * address review comments * move validity checks to logged branch * RedisModule_GetClusterNodeSlotRanges never returns NULL * add defensive check back * fix security concern --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> (cherry picked from commit 9a6b9b1)




Describe the changes in the pull request
search.CLUSTERSETaccepts only the long form (MYID … RANGES n SHARD … SLOTRANGE … ADDR … MASTER …), which forces the orchestrator to enumerate every shard's slot range, host, and port.search.CLUSTERSET AUTH <password>, that builds the topology directly from the Redis Module cluster API. The newMRClusterTopology_FromAPIwalksRedisModule_GetClusterNodesList/GetClusterNodeInfo/GetClusterNodeSlotRanges, keeps master nodes that own slots, sets the password on every endpoint, and marks the local node (REDISMODULE_NODE_MYSELF) asmy_shard_idx.RedisEnterprise_ParseTopologydispatches to the short form whenargc == 3 && RedisModule_GetClusterNodeSlotRanges.RedisModule_GetClusterNodeSlotRanges(upstream Redis PR Add RM_GetClusterNodeSlotRanges module API redis/redis#14953, planned for OSS Redis 8.10 and backported to Enterprise 8.4), the orchestrator can send a 3-argumentsearch.CLUSTERSET AUTH <pw>and the module computes the topology itself. Long-form behavior is unchanged when the gate isn't taken.Which additional issues this PR fixes
Main objects this PR modified
MRClusterTopology_FromAPI(new) —src/coord/rmr/cluster_topology.c. Manages module-owned slot range arrays explicitly viaRedisModule_ClusterFreeSlotRanges(per PR review preference to avoidRedisModule_AutoMemory).parse_topology_short_form(new) andRedisEnterprise_ParseTopologydispatch —src/coord/rmr/redise.cRedisModule_GetClusterNodeSlotRangesdeclaration added tosrc/redismodule.hat the same position upstream places it (next toGetClusterNodeInfo/GetClusterNodesList); to be removed when the file is re-synced from upstream after #14953 lands.GetClusterNodesList,GetClusterNodeInfo,GetMyClusterID,GetClusterSize,GetClusterNodeSlotRanges,FreeClusterNodesList) —tests/cpptests/redismock/MRClusterTopology_FromAPI(test_cpp_cluster_topology.cpp) and 5 dispatch/short-form tests appended totest_cpp_clusterset.cpp. Verified end-to-end against a 3-node cluster built from #14953.Mark if applicable
The API change is the new
search.CLUSTERSET AUTH <password>short form. The long form is untouched.Release Notes
search.CLUSTERSETnow accepts a 3-argument short form,search.CLUSTERSET AUTH <password>, on hosts that exposeRedisModule_GetClusterNodeSlotRanges(OSS Redis 8.10+ / Enterprise 8.4+ backport). The orchestrator no longer needs to spell out shards and slot ranges — the module fetches them from the cluster.Follow-up
src/redismodule.his re-synced from upstream after #14953 lands, drop the manual declaration ofRedisModule_GetClusterNodeSlotRangesadded here (it should already match upstream's position, so this is a straight diff).&& RedisModule_GetClusterNodeSlotRangeshalf of the dispatch gate inRedisEnterprise_ParseTopology, and use it for OSS as well instead of callingCLUSTER SHARDS.🤖 Generated with Claude Code
Note
Medium Risk
Changes how cluster topology is discovered and applied for coordinators; wrong filtering or slot cloning could mis-route queries, but long-form remains and behavior is gated on the new API pointer.
Overview
Adds a 3-argument
search.CLUSTERSET AUTH <password>path when the host exposesRedisModule_GetClusterNodeSlotRanges.MRClusterTopology_FromAPIbuilds the coordinator topology from the module cluster APIs (node list, node info, per-node slot ranges): masters with slots only, optional password on every endpoint,my_shard_idxwhen the local node is a slotted master (replica/slot-less local node staysUINT32_MAX, same as long-form).RedisEnterprise_ParseTopologyroutesargc == 3to that path; long-form parsing is unchanged otherwise.Declares
RedisModule_GetClusterNodeSlotRangesin vendoredredismodule.huntil upstream sync.SetClusterCommanddrops verbose invalid-arg / per-shard range logging. redismock gains a configurable cluster mock and tests forFromAPIand short-form dispatch.Reviewed by Cursor Bugbot for commit 35fc497. Bugbot is set up for automated code reviews on this repo. Configure here.