Repository navigation
[redis filter] Add cluster-scope command support with flexible response handling framework - #41381
Merged
yanavlasov merged 18 commits intoOct 17, 2025
Merged
Conversation
dinesh-murugiah
force-pushed
the
cluster_scope_commands
branch
from
October 8, 2025 15:39
c04c106 to
8da9ece
Compare
First commit: cluster scope command handling framework Signed-off-by: dinesh-murugiah <[email protected]>
Signed-off-by: dinesh-murugiah <[email protected]>
variables in responsehandler and added interface to handle request from response handling class, fixed other typos created by agent Signed-off-by: dinesh-murugiah <[email protected]>
validating subcommands restrictions Signed-off-by: dinesh-murugiah <[email protected]>
Signed-off-by: dinesh-murugiah <[email protected]>
Signed-off-by: dinesh-murugiah <[email protected]>
Signed-off-by: dinesh-murugiah <[email protected]>
Signed-off-by: dinesh-murugiah <[email protected]>
Signed-off-by: dinesh-murugiah <[email protected]>
Signed-off-by: dinesh-murugiah <[email protected]>
Signed-off-by: dinesh-murugiah <[email protected]>
Signed-off-by: dinesh-murugiah <[email protected]>
Signed-off-by: dinesh-murugiah <[email protected]>
Signed-off-by: dinesh-murugiah <[email protected]>
dinesh-murugiah
force-pushed
the
cluster_scope_commands
branch
from
October 8, 2025 16:12
8da9ece to
b24a6d8
Compare
Contributor
Author
|
@yanavlasov @mattklein123 kind request to review |
yanavlasov
reviewed
Oct 16, 2025
yanavlasov
left a comment
Contributor
There was a problem hiding this comment.
LGTM, but the changelog needs clean-up.
/wait
| Removed runtime guard ``envoy.reloadable_features.original_src_fix_port_exhaustion`` and legacy code paths. | ||
|
|
||
| new_features: | ||
| - area: router |
Contributor
There was a problem hiding this comment.
It looks like a bad merge.
Contributor
Author
There was a problem hiding this comment.
@yanavlasov thanks for your efforts to review , i have fixed the merge problem
Signed-off-by: dinesh-murugiah <[email protected]>
dinesh-murugiah
force-pushed
the
cluster_scope_commands
branch
from
October 17, 2025 07:17
1ba4aa8 to
3f027c2
Compare
Signed-off-by: yanavlasov <[email protected]>
yanavlasov
approved these changes
Oct 17, 2025
yanavlasov
enabled auto-merge (squash)
October 17, 2025 12:29
mattklein123
pushed a commit
that referenced
this pull request
Aug 18, 2026
**Commit Message**: redis filter: support `CLUSTER SHARDS` Adds ``shards`` to the CLUSTER subcommand allowlist so cluster-aware clients can issue CLUSTER SHARDS (Redis 7.0+, the successor to the deprecated CLUSTER SLOTS) through the proxy. Like the other supported CLUSTER introspection subcommands (INFO, SLOTS, KEYSLOT, NODES), the command is forwarded to a single random upstream shard and the reply is returned to the client unmodified. See [here](https://redis.io/docs/latest/commands/cluster-shards/) for `CLUSTER SHARDS` docs. **Additional Description**: This builds on the random-shard command framework introduced in #41381: subcommand validation is data-driven via `commandSubcommandValidationMap()`, and routing/response handling reuse the existing `RandomShardRequest` passthrough (works identically for RESP2 and RESP3 connections since the reply is relayed verbatim). On upstreams older than Redis 7.0, the upstream's `ERR unknown subcommand` error is passed through to the client unchanged. I guess I can also add a small comment on why this is needed - we have a case where we want to use Envoy to fetch Redis cluster state before initializing a client, e.g. ruby `redis-cluster-client`. This library, however, first calls `CLUSTER SHARDS` and only then falls back to `CLUSTER NODES`. See [here](https://github.com/redis-rb/redis-cluster-client/blob/25603bb42d15e3c719a3e505891ce3e425a4d225/lib/redis_client/cluster/node.rb#L357-L365). Having Envoy support `CLUSTER SHARDS` would help us save some network roundtrips and potentially avoid thundering herd problem on our network links during large scale app rollouts. **Related issues, not fixed by this PR**: #38492 tracks broader redis_proxy command coverage; #36975 asks for Envoy's own cluster topology discovery to use CLUSTER SHARDS, which is out of scope here (discovery still uses CLUSTER SLOTS). **Per the generative AI policy**: this change was developed with the assistance of an AI tool (Claude Code). I have reviewed the change, understand it fully, and take ownership of it. **Risk Level**: Low — additive one-line allowlist change enabling passthrough of a single read-only introspection subcommand; no behavior change for any existing command. **Testing**: New unit test `RandomShardRequestTest.ClusterShards`, mirroring the existing `ClusterNodes` test. The full `//test/extensions/filters/network/redis_proxy:command_splitter_impl_test` target passes (249/249 tests), including the existing unsupported-subcommand rejection tests. `ci/do_ci.sh format` passes. **Docs Changes**: Added a ``CLUSTER SHARDS, Generic`` row to the supported commands table in `docs/root/intro/arch_overview/other_protocols/redis.rst`. **Release Notes**: `changelogs/current/new_features/redis_proxy__cluster-shards-command.rst` **Platform Specific Features**: N/A Signed-off-by: Aurimas Ragulis <[email protected]>
phlax
pushed a commit
to phlax/envoy
that referenced
this pull request
Aug 18, 2026
**Commit Message**: redis filter: support `CLUSTER SHARDS` Adds ``shards`` to the CLUSTER subcommand allowlist so cluster-aware clients can issue CLUSTER SHARDS (Redis 7.0+, the successor to the deprecated CLUSTER SLOTS) through the proxy. Like the other supported CLUSTER introspection subcommands (INFO, SLOTS, KEYSLOT, NODES), the command is forwarded to a single random upstream shard and the reply is returned to the client unmodified. See [here](https://redis.io/docs/latest/commands/cluster-shards/) for `CLUSTER SHARDS` docs. **Additional Description**: This builds on the random-shard command framework introduced in envoyproxy#41381: subcommand validation is data-driven via `commandSubcommandValidationMap()`, and routing/response handling reuse the existing `RandomShardRequest` passthrough (works identically for RESP2 and RESP3 connections since the reply is relayed verbatim). On upstreams older than Redis 7.0, the upstream's `ERR unknown subcommand` error is passed through to the client unchanged. I guess I can also add a small comment on why this is needed - we have a case where we want to use Envoy to fetch Redis cluster state before initializing a client, e.g. ruby `redis-cluster-client`. This library, however, first calls `CLUSTER SHARDS` and only then falls back to `CLUSTER NODES`. See [here](https://github.com/redis-rb/redis-cluster-client/blob/25603bb42d15e3c719a3e505891ce3e425a4d225/lib/redis_client/cluster/node.rb#L357-L365). Having Envoy support `CLUSTER SHARDS` would help us save some network roundtrips and potentially avoid thundering herd problem on our network links during large scale app rollouts. **Related issues, not fixed by this PR**: envoyproxy#38492 tracks broader redis_proxy command coverage; envoyproxy#36975 asks for Envoy's own cluster topology discovery to use CLUSTER SHARDS, which is out of scope here (discovery still uses CLUSTER SLOTS). **Per the generative AI policy**: this change was developed with the assistance of an AI tool (Claude Code). I have reviewed the change, understand it fully, and take ownership of it. **Risk Level**: Low — additive one-line allowlist change enabling passthrough of a single read-only introspection subcommand; no behavior change for any existing command. **Testing**: New unit test `RandomShardRequestTest.ClusterShards`, mirroring the existing `ClusterNodes` test. The full `//test/extensions/filters/network/redis_proxy:command_splitter_impl_test` target passes (249/249 tests), including the existing unsupported-subcommand rejection tests. `ci/do_ci.sh format` passes. **Docs Changes**: Added a ``CLUSTER SHARDS, Generic`` row to the supported commands table in `docs/root/intro/arch_overview/other_protocols/redis.rst`. **Release Notes**: `changelogs/current/new_features/redis_proxy__cluster-shards-command.rst` **Platform Specific Features**: N/A Signed-off-by: Aurimas Ragulis <[email protected]>
Wenwei-Zhao
pushed a commit
to Wenwei-Zhao/envoy
that referenced
this pull request
Aug 18, 2026
**Commit Message**: redis filter: support `CLUSTER SHARDS` Adds ``shards`` to the CLUSTER subcommand allowlist so cluster-aware clients can issue CLUSTER SHARDS (Redis 7.0+, the successor to the deprecated CLUSTER SLOTS) through the proxy. Like the other supported CLUSTER introspection subcommands (INFO, SLOTS, KEYSLOT, NODES), the command is forwarded to a single random upstream shard and the reply is returned to the client unmodified. See [here](https://redis.io/docs/latest/commands/cluster-shards/) for `CLUSTER SHARDS` docs. **Additional Description**: This builds on the random-shard command framework introduced in envoyproxy#41381: subcommand validation is data-driven via `commandSubcommandValidationMap()`, and routing/response handling reuse the existing `RandomShardRequest` passthrough (works identically for RESP2 and RESP3 connections since the reply is relayed verbatim). On upstreams older than Redis 7.0, the upstream's `ERR unknown subcommand` error is passed through to the client unchanged. I guess I can also add a small comment on why this is needed - we have a case where we want to use Envoy to fetch Redis cluster state before initializing a client, e.g. ruby `redis-cluster-client`. This library, however, first calls `CLUSTER SHARDS` and only then falls back to `CLUSTER NODES`. See [here](https://github.com/redis-rb/redis-cluster-client/blob/25603bb42d15e3c719a3e505891ce3e425a4d225/lib/redis_client/cluster/node.rb#L357-L365). Having Envoy support `CLUSTER SHARDS` would help us save some network roundtrips and potentially avoid thundering herd problem on our network links during large scale app rollouts. **Related issues, not fixed by this PR**: envoyproxy#38492 tracks broader redis_proxy command coverage; envoyproxy#36975 asks for Envoy's own cluster topology discovery to use CLUSTER SHARDS, which is out of scope here (discovery still uses CLUSTER SLOTS). **Per the generative AI policy**: this change was developed with the assistance of an AI tool (Claude Code). I have reviewed the change, understand it fully, and take ownership of it. **Risk Level**: Low — additive one-line allowlist change enabling passthrough of a single read-only introspection subcommand; no behavior change for any existing command. **Testing**: New unit test `RandomShardRequestTest.ClusterShards`, mirroring the existing `ClusterNodes` test. The full `//test/extensions/filters/network/redis_proxy:command_splitter_impl_test` target passes (249/249 tests), including the existing unsupported-subcommand rejection tests. `ci/do_ci.sh format` passes. **Docs Changes**: Added a ``CLUSTER SHARDS, Generic`` row to the supported commands table in `docs/root/intro/arch_overview/other_protocols/redis.rst`. **Release Notes**: `changelogs/current/new_features/redis_proxy__cluster-shards-command.rst` **Platform Specific Features**: N/A Signed-off-by: Aurimas Ragulis <[email protected]> Signed-off-by: Wenwei Zhao <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit Message
Add cluster-scope command support with flexible response handling framework
This commit introduces a comprehensive framework for handling Redis cluster-scope commands (CONFIG, SLOWLOG, SCRIPT, FLUSHALL, FLUSHDB) that need to be broadcast to all shards with specialized response aggregation logic.
Additional Description
Problem Statement
Previously, Redis cluster-scope commands were not properly supported. These commands need to:
Be sent to all shards in the cluster
Have responses aggregated according to command-specific logic
Handle partial failures gracefully
Design Approach
Implemented a flexible response handler framework using the Strategy and Template Method patterns:
BaseClusterScopeResponseHandler: Abstract base class providing common response collection logic via template method pattern
AllshardSameResponseHandler: Validates all shards return identical responses (e.g., CONFIG SET, FLUSHALL)
IntegerSumAggregateResponseHandler: Sums integer responses across shards (e.g., SLOWLOG LEN)
ArrayMergeAggregateResponseHandler: Merges array responses from all shards (e.g., SLOWLOG GET, CONFIG GET)
Factory Pattern for Handler Creation
ClusterResponseHandlerFactory dynamically creates appropriate handlers based on command and subcommand, enabling easy extensibility for new commands.
Command Routing Architecture
Added ClusterScopeCommands() to SupportedCommands for command classification
Created ClusterScopeCmdRequest class that broadcasts commands to all shards
Implemented subcommand validation via commandSubcommandValidationMap() to restrict unsupported subcommand variants, this helpus restrict certain subcommands from being implemented
Separation of Concerns: Response handling logic is isolated from request routing logic
Extensibility: New cluster-scope commands require only adding handler logic and factory mapping
Error Handling: Failures are converted to error responses and handled uniformly; partial failures return first error encountered
Memory Efficiency: Pre-allocate response vectors based on shard count to minimize allocations
Implementation Details
Response Handler Lifecycle:
ClusterScopeCmdRequest::create() initializes handler via factory
Requests sent to all shards concurrently
Each response/failure triggers handleResponse()/handleFailure()
After all responses received, processAllResponses() performs command-specific aggregation
Final result sent via callbacks_.onResponse()
Risk Level: LOW - Changes are additive and isolated to new cluster-scope command handling. Existing command paths remain unchanged.
Testing
Comprehensive test coverage added in redis_command_splitter_impl_test.cc:
All shards return same response (success case)
Different responses from shards (validation failure)
Single shard error handling
Single shard failure handling
No upstream hosts available
Partial upstream host failures
Request cancellation
Mirrored request support
Correct handler creation for all supported commands
Handler type verification (AllshardSame, IntegerSum, ArrayMerge)
Supported commands route correctly
Zero shards handled gracefully
Unsupported commands/subcommands rejected with appropriate errors
Integer overflow handling in sum aggregation
Empty array responses
Null/unexpected response types
Negative integer values (rejected)
Single vs. multi-shard response unwrapping
Test Statistics:
25+ new test cases covering cluster-scope functionality
Tests verify correct stats increments (success/error/latency)
Mock-based testing ensures no external dependencies
Docs Changes
current.yaml: Updated with new cluster-scope command support
redis.rst: Documentation for supported cluster-scope commands and their behavior
Release Notes
Added support for Redis cluster-scope commands (CONFIG, SLOWLOG, SCRIPT, FLUSHALL, FLUSHDB) with intelligent response aggregation. Commands are automatically broadcast to all cluster shards with responses merged according to command semantics.
Platform Specific Features
None - implementation is platform-agnostic.