Skip to content

xds/resolver: pass route's auto_host_rewrite to LB picker (gRFC A81)#8740

Merged
Pranjali-2501 merged 7 commits into
grpc:masterfrom
Pranjali-2501:configSelector-changes
Dec 11, 2025
Merged

xds/resolver: pass route's auto_host_rewrite to LB picker (gRFC A81)#8740
Pranjali-2501 merged 7 commits into
grpc:masterfrom
Pranjali-2501:configSelector-changes

Conversation

@Pranjali-2501

@Pranjali-2501 Pranjali-2501 commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

This PR implements the ConfigSelector changes required for gRFC A81.

It ensures that the auto_host_rewrite field from the xDS Route Configuration is correctly propagated through the resolver and made available to the Load Balancer picker via the RPC context.

Key Changes:

  • Pass the AutoHostRewrite field value from Route struct via RPC context.
  • Add helper functions for AutoHostRewrite in internal/xds/balancer/cluserimpl/picker.go.
  • Update ConfigSelector.SelectConfig to pass the AutoHostRewrite boolean in RPC context.

RELEASE NOTES: None

@Pranjali-2501 Pranjali-2501 added Type: Feature New features or improvements in behavior Area: xDS Includes everything xDS related, including LB policies used with xDS. labels Dec 3, 2025
@Pranjali-2501 Pranjali-2501 changed the title xds/resolver: propagate route's auto_host_rewrite field in MatchedRoute (gRFC A81) xds/resolver: pass route's auto_host_rewrite to LB picker (gRFC A81) Dec 3, 2025
@Pranjali-2501 Pranjali-2501 added this to the 1.78 Release milestone Dec 3, 2025
@codecov

codecov Bot commented Dec 3, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.47%. Comparing base (4c27cc8) to head (9cbcc98).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8740      +/-   ##
==========================================
+ Coverage   83.28%   83.47%   +0.18%     
==========================================
  Files         418      418              
  Lines       32367    32434      +67     
==========================================
+ Hits        26958    27073     +115     
+ Misses       4034     3991      -43     
+ Partials     1375     1370       -5     
Files with missing lines Coverage Δ
internal/xds/balancer/clusterimpl/picker.go 97.40% <100.00%> (+0.25%) ⬆️
internal/xds/resolver/serviceconfig.go 88.05% <100.00%> (+0.08%) ⬆️
internal/xds/resolver/xds_resolver.go 88.63% <100.00%> (+0.06%) ⬆️

... and 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@easwars

easwars commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

Sorry for suggesting that we could possibly send the whole route instead of sending only the auto_host_rewrite field, as specified in A60. After reading A60, I realized that sending the whole route down is not as simple as just stashing a pointer to the route in an attribute. We need to take into account things like reference counts to the route and the selected cluster and the whole cluster map.

So, let's keep it simple for now and just add an attribute that carries the auto_host_rewrite just like how we pass the selected cluster name from the config selector to the LB policy. Thanks.

@easwars easwars assigned Pranjali-2501 and unassigned easwars Dec 4, 2025

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

Also please remove any mentions to MatchedRoute from the PR description and from comments in the PR.

Comment thread internal/xds/resolver/serviceconfig.go Outdated
Comment thread internal/xds/resolver/serviceconfig.go Outdated
Comment thread internal/xds/resolver/xds_resolver_test.go Outdated
@easwars easwars assigned Pranjali-2501 and unassigned easwars Dec 4, 2025
Comment thread internal/xds/balancer/clusterimpl/picker.go Outdated
Comment thread internal/xds/balancer/clusterimpl/picker.go Outdated
Comment thread internal/xds/balancer/clusterimpl/picker.go Outdated
Comment thread internal/xds/resolver/xds_resolver_test.go Outdated
Comment thread internal/xds/resolver/xds_resolver_test.go Outdated
Comment thread internal/xds/resolver/xds_resolver_test.go Outdated
Comment thread internal/xds/resolver/xds_resolver_test.go Outdated
Comment thread internal/xds/resolver/xds_resolver_test.go Outdated
Comment thread internal/xds/resolver/xds_resolver_test.go Outdated
Comment thread internal/xds/resolver/xds_resolver_test.go Outdated
@easwars easwars assigned Pranjali-2501 and unassigned easwars Dec 8, 2025
@Pranjali-2501 Pranjali-2501 removed their assignment Dec 9, 2025

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

LGTM, modulo one minor comment

Comment on lines +204 to +205
autohostRewrite, _ := ctx.Value(autoHostRewriteKey{}).(bool)
return autohostRewrite

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.

Nit: maybe rename the variable with a one letter name. Something like v?

See: go/go-style/decisions#variable-names

TL;Dr
The general rule of thumb is that the length of a name should be proportional to the size of its scope and inversely proportional to the number of times that it is used within that scope

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread internal/xds/resolver/xds_resolver_test.go
@easwars easwars assigned Pranjali-2501 and unassigned easwars Dec 10, 2025
@Pranjali-2501 Pranjali-2501 merged commit d35cedd into grpc:master Dec 11, 2025
14 checks passed
Pranjali-2501 added a commit that referenced this pull request Jan 5, 2026
…icy (gRFC A81) (#8779)

This PR implements the xDS :authority header rewriting feature as
specified in [gRFC
A81](https://github.com/grpc/proposal/blob/master/A81-xds-authority-rewriting.md)

### Key Changes:

* xds_cluster_impl LB Policy:
* Updated the Picker to check for the auto_host_rewrite flag (passed via
ConfigSelector).
* If enabled, the picker retrieves the hostname attribute from the
subchannel .
* The picker populates the Metadata field in PickResult with the new
:authority value.

* changes in  stream.go:
* Updated stream.go to inspect the PickResult metadata. If an :authority
override is present and the user has not explicitly set an authority via
CallOption, the `callHdr.Authority` is updated with hostname.
   
* PR relies on the following changes already merged:
* Bootstrap config change (#8692): Added the trusted_xds_server server
feature to the bootstrap configuration.
* xDS resource validation (#8728): Implemented validation and extraction
of the auto_host_rewrite field from RDS resources and the hostname field
from EDS resources.
* Endpoint Structure (#8750): Refactored xdsresource.Endpoint to use
resolver.Endpoint, ensuring that attributes (like the endpoint's
hostname) are correctly stored and accessible to the picker.
* xDS ConfigSelector changes (#8740): Updated the xDS resolver to
propagate the auto_host_rewrite flag from the Route Configuration to the
Load Balancer via the ConfigSelector.

RELEASE NOTES: 
* xDS: Added support for the :authority rewriting (gRFC A81). When
`autoHostRewrite` is enabled in the xDS RouteConfiguration, the client
will rewrite the HTTP/2 :authority header to the value of the selected
endpoint's hostname.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: xDS Includes everything xDS related, including LB policies used with xDS. Type: Feature New features or improvements in behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants