Skip to content

dynamic_modules: add virtual cluster selection to the route specifier - #48899

Open
agrawroh wants to merge 3 commits into
envoyproxy:mainfrom
agrawroh:route-specifier-virtual-cluster-selection
Open

agrawroh wants to merge 3 commits into
envoyproxy:mainfrom
agrawroh:route-specifier-virtual-cluster-selection

Conversation

@agrawroh

@agrawroh agrawroh commented Nov 1, 2026

Copy link
Copy Markdown
Member

Description

This PR adds virtual cluster selection to the dynamic modules route specifier. A module selects the virtual cluster of a request from the names the configuration declares. The selection uses the statistics of the virtual cluster of the same name on the virtual host. The router either compares the selection with the virtual host or prefers it and skips the linear scan.


Commit Message: dynamic_modules: add virtual cluster selection to the route specifier
Risk Level: Low
Testing: Added Tests
Docs Changes: Added
Release Notes: Added

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @wbpcode
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #48899 was opened by agrawroh.

see: more, trace.

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
What changed in this PR

This PR adds virtual cluster selection support to the dynamic modules route specifier, allowing modules to label requests with a declared virtual cluster and optionally prefer that selection over the virtual host’s linear scan while maintaining consistent virtual-cluster statistics.

Changes:

  • Add set_virtual_cluster callback and plumbing to carry a virtual-cluster selection through dynamic-module routing and built-route-cache behavior.
  • Introduce a shared registry of declared virtual clusters and a virtual-host/route wrapper to supply the selected virtual cluster to the router.
  • Add extensive unit/integration tests plus API/docs/changelog updates for the new configuration and behavior.
File Description
test/​extensions/​router/​route_specifiers/​dynamic_modules/​route_specifier_test.cc Adds unit tests covering selection, comparison, logging, caching interactions, and registry behavior.
test/​extensions/​router/​route_specifiers/​dynamic_modules/​integration_test.cc Adds integration coverage for preferred vs compared selection and stats/tag expectations.
test/​extensions/​router/​route_specifiers/​dynamic_modules/​BUILD Adds deps and test module target needed for virtual cluster selection tests.
test/​extensions/​dynamic_modules/​test_data/​rust/​route_specifier_integration_test.rs Extends Rust test module behavior to drive set_virtual_cluster via request headers.
test/​extensions/​dynamic_modules/​test_data/​c/​route_specifier_virtual_cluster.c Adds a C test module that selects virtual clusters and exercises edge cases (unknown/null buffer).
test/​extensions/​dynamic_modules/​test_data/​c/​route_specifier_built_route_cache.c Extends built-route-cache test module to vary on virtual cluster selection.
test/​extensions/​dynamic_modules/​test_data/​c/​BUILD Registers the new C test program target.
test/​extensions/​dynamic_modules/​abi_impl_test.cc Adds weak stub for the new ABI callback used in tests.
source/​extensions/​router/​route_specifiers/​dynamic_modules/​route_specifier.h Adds declared virtual cluster types/registry, selection-carrying wrappers, config fields, and stats.
source/​extensions/​router/​route_specifiers/​dynamic_modules/​route_specifier.cc Implements declared vcluster stats creation, registry lifecycle/sweeping, wrapper behavior, and selection dropping.
source/​extensions/​router/​route_specifiers/​dynamic_modules/​abi_impl.cc Implements envoy_dynamic_module_callback_route_specifier_set_virtual_cluster.
source/​extensions/​router/​route_specifiers/​dynamic_modules/​BUILD Adds required deps for router context/singletons/stats helpers and absl containers/hash.
source/​extensions/​dynamic_modules/​sdk/​rust/​src/​route_specifier.rs Adds Rust SDK API surface set_virtual_cluster with documentation.
source/​extensions/​dynamic_modules/​sdk/​rust/​src/​lib_test.rs Adds Rust SDK unit test coverage and stub implementation for set_virtual_cluster.
source/​extensions/​dynamic_modules/​abi_impl.cc Adds a weak stub for the new ABI callback in the dynamic modules ABI impl.
source/​extensions/​dynamic_modules/​abi/​abi.h Documents and declares the new C ABI callback for virtual cluster selection.
docs/​root/​configuration/​http/​route_specifier/​dynamic_modules.rst Documents config semantics, counters, logging, and operational guidance for selection/comparison.
changelogs/​current/​new_features/​dynamic_modules__route-specifier-virtual-cluster-selection.rst Adds release note for the new feature.
api/​envoy/​extensions/​router/​route_specifiers/​dynamic_modules/​v3/​dynamic_modules.proto Adds VirtualClusterSelection message + virtual_cluster_selection field in the specifier config.

Review effort: Lite

Copilot stopped reviewing on behalf of agrawroh due to an error November 1, 2026 01:45
Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
@agrawroh
agrawroh force-pushed the route-specifier-virtual-cluster-selection branch from b21199c to 6e83ec1 Compare November 1, 2026 06:48
@agrawroh
agrawroh requested a max review from Copilot November 1, 2026 07:28

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

Comment on lines +272 to +277
const Stats::StatNameTag tags[] = {{well_known.tag_virtual_host_, virtual_host},
{well_known.tag_virtual_cluster_, virtual_cluster}};
const Stats::StatNameJoiner base_prefix({well_known.vhost_, well_known.vcluster_}, symbol_table);
const Stats::StatNameJoiner prefix(
{well_known.vhost_, virtual_host, well_known.vcluster_, virtual_cluster}, symbol_table);
Stats::LiteScopeHelper helper(scope, base_prefix.statName(), tags, prefix.statName());

@wbpcode wbpcode left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this contribution. Let's get agreement about the API first.

@wbpcode

wbpcode commented Nov 1, 2026

Copy link
Copy Markdown
Member

/wait

Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants