Skip to content

xds: change clusterimpl to add SNI to handshake info#9016

Merged
eshitachandwani merged 7 commits into
grpc:masterfrom
eshitachandwani:final_a101_PR
Apr 7, 2026
Merged

xds: change clusterimpl to add SNI to handshake info#9016
eshitachandwani merged 7 commits into
grpc:masterfrom
eshitachandwani:final_a101_PR

Conversation

@eshitachandwani
Copy link
Copy Markdown
Member

@eshitachandwani eshitachandwani commented Mar 25, 2026

This PR is the final PR for implementation of gRFC A101

This PR does the following :

  • Change NewSubconn in ClusterImpl to add the hostname to attribute of the address so that it can be propagated to the ClientHandshake and retrieved there to decide the SNI which can be either DNS Hostname or endpoint Hostname if AutoHostSni is set , or the SNI received from control plane. This is done because each endpoint can have a different hostname. It is not a config that can be used across all endpoints of the cluster , so it cannot be set in handshake info.
  • Add AutoHostSni filed to the handshake info.
  • Adds a functions to set and get hostname from address attributes. As of now, there was a function to get the Hostname from address balancer.Attributes and set in endpoint atrributes.
  • Adds E2E tests to verify the complete SNI setting and validation flow.
  • Fix comments that mention CDS balancer creates handshake info.

Note: We will turn the environment variable to true only after inter-op tests pass.

RELEASE NOTES:

  • xds: add SNI support and SAN validation behind GRPC_EXPERIMENTAL_XDS_SNI (gRFC A101)

@eshitachandwani eshitachandwani added this to the 1.81 Release milestone Mar 25, 2026
@eshitachandwani eshitachandwani added Type: Feature New features or improvements in behavior Area: xDS Includes everything xDS related, including LB policies used with xDS. labels Mar 25, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 91.89189% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.05%. Comparing base (2b8b708) to head (90ae462).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
internal/credentials/xds/handshake_info.go 87.50% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9016      +/-   ##
==========================================
+ Coverage   83.01%   83.05%   +0.03%     
==========================================
  Files         413      413              
  Lines       33054    33269     +215     
==========================================
+ Hits        27441    27630     +189     
- Misses       4205     4219      +14     
- Partials     1408     1420      +12     
Files with missing lines Coverage Δ
credentials/xds/xds.go 89.01% <100.00%> (+0.12%) ⬆️
internal/xds/balancer/clusterimpl/clusterimpl.go 88.25% <100.00%> (+0.43%) ⬆️
internal/xds/server/conn_wrapper.go 76.27% <100.00%> (ø)
internal/credentials/xds/handshake_info.go 93.06% <87.50%> (-0.65%) ⬇️

... and 36 files with indirect coverage changes

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

@eshitachandwani eshitachandwani requested review from Pranjali-2501 and easwars and removed request for easwars March 25, 2026 12:41
@easwars
Copy link
Copy Markdown
Contributor

easwars commented Mar 26, 2026

The release note seems to be too long. How about:

  • xds: support SNI and server SAN validation (gRFC A101), or
  • xds: add SNI support and SAN validation behind GRPC_EXPERIMENTAL_XDS_SNI (gRFC A101)

Comment thread internal/xds/balancer/clusterimpl/clusterimpl.go Outdated
Comment thread internal/xds/balancer/clusterimpl/clusterimpl.go Outdated
Comment thread test/xds/xds_client_sni_test.go Outdated
Comment thread test/xds/xds_client_sni_test.go Outdated
Comment thread test/xds/xds_client_sni_test.go Outdated
Comment thread test/xds/xds_client_sni_test.go
@eshitachandwani
Copy link
Copy Markdown
Member Author

The release note seems to be too long. How about:

  • xds: support SNI and server SAN validation (gRFC A101), or
  • xds: add SNI support and SAN validation behind GRPC_EXPERIMENTAL_XDS_SNI (gRFC A101)

Changed.

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 comments and nits

// ClientSideTLSConfig constructs a tls.Config to be used in a client-side
// handshake based on the contents of the HandshakeInfo.
func (hi *HandshakeInfo) ClientSideTLSConfig(ctx context.Context) (*tls.Config, error) {
func (hi *HandshakeInfo) ClientSideTLSConfig(ctx context.Context, hostname string) (*tls.Config, error) {
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.

Please comment on why hostname is passed as a parameter here instead of it being part of the HandshakeInfo.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.


}

type mockProvider struct {
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.

There is no mocking happening here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Changed the name to testProviderWithRoots

}
// Store hostname in the address attributes, so that it can be used in
// the client handshake.
newAddrs[i] = xds.SetEndpointHostname(newAddrs[i], hostname)
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.

This function name is and can be quite confusing, because it takes a resolver.Address, but contains the term Endpoint in it. Can you think of a better name?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

changed it to SetAddressHostname

Comment thread test/xds/xds_client_sni_test.go Outdated
Comment on lines +67 to +69
// Create test backends for two clusters
// backend1 configured with TLS creds, represents cluster1 (valid SNI)
// backend2 configured with TLS creds, represents cluster2 (invalid SNI)
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:

Suggested change
// Create test backends for two clusters
// backend1 configured with TLS creds, represents cluster1 (valid SNI)
// backend2 configured with TLS creds, represents cluster2 (invalid SNI)
// Create test backends for two clusters:
// - backend1 configured with TLS creds, represents cluster1 (valid SNI)
// - backend2 configured with TLS creds, represents cluster2 (invalid SNI)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

Comment thread test/xds/xds_client_sni_test.go Outdated
Comment on lines +310 to +316
// Create test backends
serverCreds := testutils.CreateServerTLSCredentials(t, tls.RequireAndVerifyClientCert)
server1 := stubserver.StartTestService(t, nil, grpc.Creds(serverCreds))
defer server1.Stop()

server2 := stubserver.StartTestService(t, nil, grpc.Creds(serverCreds))
defer server2.Stop()
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: here and elsewhere

Suggested change
// Create test backends
serverCreds := testutils.CreateServerTLSCredentials(t, tls.RequireAndVerifyClientCert)
server1 := stubserver.StartTestService(t, nil, grpc.Creds(serverCreds))
defer server1.Stop()
server2 := stubserver.StartTestService(t, nil, grpc.Creds(serverCreds))
defer server2.Stop()
// Create test backends.
serverCreds := testutils.CreateServerTLSCredentials(t, tls.RequireAndVerifyClientCert)
server1 := stubserver.StartTestService(t, nil, grpc.Creds(serverCreds))
defer server1.Stop()
server2 := stubserver.StartTestService(t, nil, grpc.Creds(serverCreds))
defer server2.Stop()

Copy link
Copy Markdown
Member 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 eshitachandwani and unassigned easwars Apr 7, 2026
@eshitachandwani eshitachandwani merged commit 71849e8 into grpc:master Apr 7, 2026
14 checks passed
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.

3 participants