Skip to content

xdsclient/xdsresource: add AutoHostRewrite and Endpoint Hostname support#8728

Merged
Pranjali-2501 merged 3 commits intogrpc:masterfrom
Pranjali-2501:resource
Dec 1, 2025
Merged

xdsclient/xdsresource: add AutoHostRewrite and Endpoint Hostname support#8728
Pranjali-2501 merged 3 commits intogrpc:masterfrom
Pranjali-2501:resource

Conversation

@Pranjali-2501
Copy link
Copy Markdown
Contributor

@Pranjali-2501 Pranjali-2501 commented Nov 26, 2025

This PR implements the validation logic and extracting per endpoint Hostname attributes from xDS resources for gRFC A81

Key Changes:

  1. RDS Resource Validation :

    • The boolean value of RouteAction.auto_host_rewrite is extracted from the RDS resource and stored in route struct
    • This field is only set to true in the parsed route struct if the trusted_xds_server option is present in the ServerConfig and the global environment variable for authority overriding is enabled.
  2. EDS Resource Validation:

    • The Endpoint.hostname field is extracted from the EDS resource and will be stored as a hostname string in parsed endpoint struct. It will be changed to be an per-endpoint resolver attribute in a follow-up PR.

RELEASE NOTES: None

@Pranjali-2501 Pranjali-2501 added this to the 1.78 Release milestone Nov 26, 2025
@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 Nov 26, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.19%. Comparing base (a764d3f) to head (d8f997f).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8728      +/-   ##
==========================================
- Coverage   83.21%   83.19%   -0.02%     
==========================================
  Files         419      419              
  Lines       32443    32454      +11     
==========================================
+ Hits        26997    27001       +4     
- Misses       4056     4064       +8     
+ Partials     1390     1389       -1     
Files with missing lines Coverage Δ
internal/envconfig/envconfig.go 100.00% <ø> (ø)
internal/xds/xdsclient/xdsresource/filter_chain.go 93.92% <100.00%> (+0.55%) ⬆️
...ds/xdsclient/xdsresource/listener_resource_type.go 96.15% <100.00%> (ø)
...dsclient/xdsresource/route_config_resource_type.go 93.33% <100.00%> (ø)
...nternal/xds/xdsclient/xdsresource/unmarshal_eds.go 94.32% <100.00%> (+0.04%) ⬆️
...nternal/xds/xdsclient/xdsresource/unmarshal_lds.go 88.46% <100.00%> (ø)
...nternal/xds/xdsclient/xdsresource/unmarshal_rds.go 87.74% <100.00%> (+0.14%) ⬆️

... and 25 files with indirect coverage changes

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

Copy link
Copy Markdown
Contributor

@easwars easwars left a comment

Choose a reason for hiding this comment

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

The PR description says:

  • This string value is included as a per-endpoint resolver attribute (hostname) in the parsed resource struct.

But the PR only stores it as a string, and not as a resolver attribute. The per-endpoint resolver attribute is defined here:

Attributes *attributes.Attributes

This means that the parsed Endpoint struct defined here:

needs to be changed to contain a resolver.Endpoint instead of a slice of address strings, and the newly added HostName field and some of the other existing things like Weight and HashKey also need to move into the endpoint attributes. This is probably big enough to be made as a separate PR though. Let's discuss this offline.

But for now, maybe the PR description need to be modified though to state that we are only storing it as a string for now and that in a follow-up PR we will change it to be an endpoint attribute.

Comment thread internal/envconfig/envconfig.go Outdated
Comment thread internal/xds/xdsclient/xdsresource/unmarshal_lds.go Outdated
Comment thread internal/xds/xdsclient/xdsresource/filter_chain.go Outdated
Comment thread internal/xds/xdsclient/xdsresource/route_config_resource_type.go Outdated
Comment thread internal/xds/xdsclient/xdsresource/unmarshal_rds_test.go Outdated
Comment thread internal/xds/xdsclient/xdsresource/unmarshal_rds_test.go Outdated
Comment thread internal/xds/xdsclient/xdsresource/unmarshal_rds_test.go Outdated
Comment thread internal/xds/xdsclient/xdsresource/unmarshal_eds_test.go Outdated
@easwars easwars assigned Pranjali-2501 and unassigned easwars Nov 26, 2025
Copy link
Copy Markdown
Contributor

@easwars easwars left a comment

Choose a reason for hiding this comment

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

LGTM modulo minor nits


tests := []struct {
name string
isTrusted bool // Corresponds to ServerConfig
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: Can we make this field be of type xdsclient.ServerFeature instead?

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 on lines +816 to +817
got := update.VirtualHosts[0].Routes[0].AutoHostRewrite
if got != test.wantResult {
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: The assignment and the conditional can be on the same line.

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.

@easwars easwars assigned Pranjali-2501 and unassigned easwars Dec 1, 2025
@Pranjali-2501 Pranjali-2501 merged commit 432bda3 into grpc:master Dec 1, 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