Skip to content

xds: Validate ring_hash requestHashHeader when parsing the config - #13161

Open
hidingmyname wants to merge 1 commit into
grpc:masterfrom
hidingmyname:xds-ring-hash-validate-request-hash-header
Open

hidingmyname wants to merge 1 commit into
grpc:masterfrom
hidingmyname:xds-ring-hash-validate-request-hash-header

Conversation

@hidingmyname

@hidingmyname hidingmyname commented Nov 2, 2026 •

Copy link
Copy Markdown

Fixes #13151

gRFC A76 says the config must be rejected if request_hash_header is not a valid header name or is a -bin header. RingHashLoadBalancerProvider accepted any string, so a bad name only failed later in RingHashLoadBalancer.acceptResolvedAddresses(). Metadata.Key.of() then threw inside the SynchronizationContext and panicked the channel. This only applies with GRPC_EXPERIMENTAL_RING_HASH_SET_REQUEST_HASH_KEY enabled.

The provider now validates the name with Metadata.Key and returns an UNAVAILABLE config error if it is invalid, like the existing minRingSize/maxRingSize check. The config now stores the lower-cased name that Metadata.Key uses.

Added three tests to RingHashLoadBalancerProviderTest: a -bin name, invalid characters and a mixed-case name. All three fail without the change. I did not add an end-to-end channel test for the panic, as it needs a custom NameResolver; I can add one if you want it.

In one full :grpc-xds:test run (4489 tests), FakeControlPlaneXdsIntegrationTest.changeClusterForRoute[enableRfc3986UrisParam=true] failed. It doesn't use ring_hash. Rerunning that class on this branch failed once and then passed 16 of 16, so it looks flaky.

gRFC A76 requires the config to be rejected if request_hash_header is
not a valid header name or ends in -bin. The provider accepted any
string, and an invalid name only failed later in
RingHashLoadBalancer.acceptResolvedAddresses(), where Metadata.Key.of()
throws inside the SynchronizationContext and panics the channel.

Validate the name in RingHashLoadBalancerProvider with the same
Metadata.Key rules and return an UNAVAILABLE config error if it is
invalid. The stored name is now the lower-cased form used by
Metadata.Key.

Fixes grpc#13151

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xds: ring_hash requestHashHeader is not validated at config parse time; a -bin or invalid header name panics the channel

1 participant