Skip to content

Conversation

@Pranjali-2501
Copy link
Contributor

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

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
Copy link

codecov bot commented Dec 3, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8740      +/-   ##
==========================================
- Coverage   83.28%   83.22%   -0.07%     
==========================================
  Files         418      418              
  Lines       32367    32378      +11     
==========================================
- Hits        26958    26947      -11     
+ Misses       4034     4028       -6     
- Partials     1375     1403      +28     
Files with missing lines Coverage Δ
internal/xds/balancer/clusterimpl/picker.go 97.40% <100.00%> (+0.25%) ⬆️
internal/xds/resolver/serviceconfig.go 67.64% <100.00%> (-20.33%) ⬇️
internal/xds/resolver/xds_resolver.go 85.79% <100.00%> (-2.78%) ⬇️

... and 27 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
Copy link
Contributor

easwars commented Dec 4, 2025

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
Copy link
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.

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

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

// GetAutoHostRewriteForTesting returns the value of autoHostRewrite feild;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: s/feild/field ?

type autoHostRewriteKey struct{}

// AutoHostRewrite retrieves the autoHostRewrite value from the provided context.
func AutoHostRewrite(ctx context.Context) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

This need not be exported, right?

return autohostRewrite
}

// GetAutoHostRewriteForTesting returns the value of autoHostRewrite feild;
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to still not have the Get prefix here: go/go-style/decisions#getters

Comment on lines +1304 to +1305
// TestResolver_AutoHostRewrite verifies the propagation of the AutoHostRewrite
// field from the xDS RouteConfiguration to the internal MatchedRoute.
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to be clear here that we are only testing if the xDS resolver correctly propagates the value of the auto_host_rewrite field, and makes it available to the picker.

Comment on lines +1304 to +1305
// TestResolver_AutoHostRewrite verifies the propagation of the AutoHostRewrite
// field from the xDS RouteConfiguration to the internal MatchedRoute.
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no more MatchedRoute struct. Please update.

wantAutoHostRewrite: false,
},
{
name: "Disable_UntrustedServer",
Copy link
Contributor

Choose a reason for hiding this comment

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

Test name is wrong. The env var is enabled here.

wantAutoHostRewrite: false,
},
{
name: "Disable_Routeconfig",
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

wantAutoHostRewrite bool
}{
{
name: "Enabled",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I sort of understand the naming of these sub-tests now. But, I think it's quite confusing. How about the following approach:

  • EnvVarDisabled_NonTrustedServer_AutoHostRewriteOff
  • EnvVarDisabled_NonTrustedServer_AutoHostRewriteOn
  • EnvVarDisabled_TrustedServer_AutoHostRewriteOff
  • EnvVarDisabled_TrustedServer_AutoHostRewriteOn
  • EnvVarEnabled_NonTrustedServer_AutoHostRewriteOff
  • EnvVarEnabled_NonTrustedServer_AutoHostRewriteOn
  • EnvVarEnabled_TrustedServer_AutoHostRewriteOff
  • EnvVarEnabled_TrustedServer_AutoHostRewriteOn

ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel()
nodeID := uuid.New().String()
mgmtServer, _, _, _ := setupManagementServerForTest(t, nodeID)
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably don't need this helper function here, since you don't use any of the returned channels from that helper function. You could instead manually start the management server here with e2e.StartManagementServer.

}},
}},
}}
configureAllResourcesOnManagementServer(ctx, t, mgmtServer, nodeID, listeners, routes, clusters, endpoints)
Copy link
Contributor

Choose a reason for hiding this comment

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

Clusters and endpoints are not required for the purposes of this test. So, you should directly call the Update method on the management server and just give it the listener and the route (you could also inline the route configuration), and set the SkipValidation field in the UpdateOptions field to true. That will make it possible to not specify all resources.

@easwars easwars assigned Pranjali-2501 and unassigned easwars Dec 8, 2025
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