dynamic_modules: add cluster filter-state read ABI#45040
Merged
Conversation
Contributor
Author
|
/coverage |
|
Coverage for this Pull Request will be rendered here: https://storage.googleapis.com/envoy-cncf-pr/45040/coverage/index.html For comparison, current coverage on https://storage.googleapis.com/envoy-cncf-postsubmit/main/coverage/index.html The coverage results are (re-)rendered each time the CI |
b3db1af to
25d45da
Compare
Adds two ABI callbacks so that a dynamic-module cluster's load balancer
can read filter state set by an upstream HTTP filter (or any other
producer) when picking a host. Today the cluster context only exposes
downstream headers, hash key, override-host, and SNI — filter state was
reachable from the C++ side via ``LoadBalancerContext::requestStreamInfo()
->filterState()`` but not surfaced through the ABI, forcing modules to
fall back to header round-tripping.
ABI additions:
* envoy_dynamic_module_callback_cluster_lb_context_get_filter_state_bytes
— reads a ``Router::StringAccessor``-typed filter state value. Mirrors
the existing HTTP-filter ``get_filter_state_bytes``.
* envoy_dynamic_module_callback_cluster_lb_context_get_filter_state_typed
— returns the serialized bytes of a typed filter state object via
``serializeAsString``. Mirrors the existing HTTP-filter
``get_filter_state_typed``. The serialized buffer is stashed in a
thread-local string so the returned pointer survives the current
host-selection callback.
Weak fallback definitions are added alongside the existing cluster-LB
weak stubs in ``source/extensions/dynamic_modules/abi_impl.cc`` so that
binaries that link the Rust SDK without the cluster_lib (e.g. the HTTP
filter integration test) still resolve cleanly.
The Rust SDK gains matching ``ClusterLbContext::get_filter_state_bytes``
and ``ClusterLbContext::get_filter_state_typed`` methods.
Tests:
* test_data/rust/cluster_filter_state_test.rs — single shared library
exporting an HTTP filter (``filter_state_producer``) that writes both
a bytes value and a typed value during ``on_request_headers``, plus a
cluster (``filter_state_reader``) whose load balancer reads both
values in ``choose_host`` and only returns its host when both
round-trip correctly.
* integration_test.cc registers an ``ObjectFactory`` for the typed key
and adds ``ReadsFilterStateProducedByHttpFilter``: prepends the
producer HTTP filter via ``prependFilter``, swaps cluster_0 for the
reader cluster, and asserts a 200 response — proving the
filter-state round trip from HTTP filter to cluster host selection.
Signed-off-by: Basundhara Chakrabarty <basundhara17061996@gmail.com>
25d45da to
4061539
Compare
Contributor
|
Needs main merge. |
…e-abi # Conflicts: # test/extensions/clusters/dynamic_modules/BUILD # test/extensions/clusters/dynamic_modules/cluster_test.cc
wbpcode
approved these changes
May 15, 2026
Member
|
/retest |
agrawroh
approved these changes
May 15, 2026
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: Adds two ABI callbacks so that a dynamic-module cluster's load balancer can read filter state set by an upstream HTTP filter (or any other producer) when picking a host.
Additional Description:
Dynamic-module clusters get two new ABI callbacks (get_filter_state_bytes and get_filter_state_typed) so a custom load balancer can read filter state during host selection. Today the cluster LB side can only see things like SNI and route metadata — it can't reach into filter state that an upstream HTTP filter (or any other producer) attached to the request. With these callbacks, an HTTP filter can compute or look up a value, stash it on filter state, and a downstream dynamic-module cluster can use that value to pick a host.
API shape
Both callbacks mirror the existing HTTP-filter equivalents so module authors see a familiar surface:
Risk Level: Low
Testing: Integration test added
Docs Changes: N.A
Release Notes: N.A
Platform Specific Features: N.A