Skip to content

redis filter: support CLUSTER SHARDS - #46480

Merged
mattklein123 merged 3 commits into
envoyproxy:mainfrom
s7eamy:feat/redis_support_cluster_shards
Aug 18, 2026
Merged

redis filter: support CLUSTER SHARDS#46480
mattklein123 merged 3 commits into
envoyproxy:mainfrom
s7eamy:feat/redis_support_cluster_shards

Conversation

@s7eamy

@s7eamy s7eamy commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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 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.

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 <aurimas.ragulis@vinted.com>
@s7eamy
s7eamy requested a review from mattklein123 as a code owner July 31, 2026 06:45
@s7eamy
s7eamy had a problem deploying to external-contributors July 31, 2026 06:45 — with GitHub Actions Error
@repokitteh-read-only

Copy link
Copy Markdown

Hi @s7eamy, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #46480 was opened by s7eamy.

see: more, trace.

@adisuissa adisuissa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assigning codeowners to review:
/assign @mattklein123 @dinesh-murugiah

@mattklein123
mattklein123 enabled auto-merge (squash) August 7, 2026 03:19
@s7eamy

s7eamy commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@mattklein123 thanks for the review. is there anything else I need to do for CI checks to pass? it seems they're waiting on authorize action

@mattklein123

Copy link
Copy Markdown
Member

I'm not sure why they are not running. Try pushing an empty commit?

Signed-off-by: Aurimas Ragulis <aurimas.ragulis@vinted.com>
@s7eamy
s7eamy deployed to external-contributors August 17, 2026 07:00 — with GitHub Actions Active
@s7eamy

s7eamy commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

retrying CI didn't help 🤔 can it be that you have to approve the workflow run somewhere here? https://github.com/envoyproxy/envoy/actions/runs/32003945969

previous run failed with:
```
  WARNING: Download from https://github.com/zlib-ng/zlib-ng/archive/2.3.2.tar.gz failed:
           java.io.IOException GET returned 429 Too Many Requests
  ERROR: no such package '@@zlib-ng//' ...
  ERROR: Analysis of target '@@envoy//tools/code_format:check_format' failed; build aborted
  INFO: Elapsed time: 177.240s
  ERROR: Build failed. Not running target
```

Signed-off-by: Aurimas Ragulis <aurimas.ragulis@vinted.com>
@s7eamy
s7eamy deployed to external-contributors August 18, 2026 06:32 — with GitHub Actions Active
@s7eamy

s7eamy commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

last run failed with:

  WARNING: Download from https://github.com/zlib-ng/zlib-ng/archive/2.3.2.tar.gz failed:
           java.io.IOException GET returned 429 Too Many Requests
  ERROR: no such package '@@zlib-ng//' ...
  ERROR: Analysis of target '@@envoy//tools/code_format:check_format' failed; build aborted
  INFO: Elapsed time: 177.240s
  ERROR: Build failed. Not running target

I pushed an empty commit again to retry workflow before realizing there's /retest :( could I get a workflow reapproval?

@phlax

phlax commented Aug 18, 2026

Copy link
Copy Markdown
Member

@mattklein123 first time contributors need to have workflows approved

its done via the environment api here

image

@mattklein123
mattklein123 merged commit e01bd1b into envoyproxy:main Aug 18, 2026
25 checks passed
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 <aurimas.ragulis@vinted.com>
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 <aurimas.ragulis@vinted.com>
Signed-off-by: Wenwei Zhao <wenweizhao@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants