Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xds: add xDS transport custom dial options support #7997

Merged
merged 18 commits into from
Jan 29, 2025

Conversation

yousukseung
Copy link
Contributor

@yousukseung yousukseung commented Jan 9, 2025

This PR extends #7586 to support multiple custom dial options.

The custom dialer option added in PR#7586 is now deprecated but not removed yet. This will be removed in a future PR after dependencies are moved to the new option.

RELEASE NOTES: N/A

@yousukseung
Copy link
Contributor Author

@danielzhaotongliu FYI

@purnesh42H purnesh42H added Type: Internal Cleanup Refactors, etc Area: xDS Includes everything xDS related, including LB policies used with xDS. labels Jan 10, 2025
@purnesh42H
Copy link
Contributor

@yousukseung we are not updating transport to use this instead yet?

@yousukseung
Copy link
Contributor Author

yousukseung commented Jan 10, 2025

@yousukseung we are not updating transport to use this instead yet?

I removed JoinDialOptions(), the ServerConfig's DialOptions() already returns []DialOption and this was not necessary.

I don't see any change needed in transport though. All changes I'm making is internal to bootstrap.go and externally it will be the same DialOptions() API. I see they are applied in Build() in grpctransport.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.19%. Comparing base (c879198) to head (a637cab).
Report is 20 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7997      +/-   ##
==========================================
+ Coverage   82.04%   82.19%   +0.14%     
==========================================
  Files         384      384              
  Lines       38750    38929     +179     
==========================================
+ Hits        31792    31996     +204     
+ Misses       5632     5595      -37     
- Partials     1326     1338      +12     
Files with missing lines Coverage Δ
internal/xds/bootstrap/bootstrap.go 65.43% <100.00%> (-3.27%) ⬇️

... and 44 files with indirect coverage changes

@purnesh42H
Copy link
Contributor

I haven't completed the review but adding @easwars as well to review in parallel

@purnesh42H purnesh42H requested a review from easwars January 13, 2025 16:55
Copy link
Contributor

@danielzhaotongliu danielzhaotongliu left a comment

Choose a reason for hiding this comment

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

Tested end-to-end in prod, the current commit work as expected.

Comment on lines 48 to 57
// testCredsBuilder implements the `Credentials` interface defined in
// package `xds/bootstrap` and encapsulates an insecure credential with a
// custom Dialer that specifies how to dial the xDS server.
type testCredsBuilder struct {
dialerCalled atomic.Bool
tagRPCCalled atomic.Bool
handleRPCCalled atomic.Bool
tagConnCalled atomic.Bool
handleConnCalled atomic.Bool
}
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 the doc string does not align with what the struct actually is? This both a custom Dialer and stats Handler.

I presume this xds_client_custom_dialopts_test.go file was originally copied from test/xds/xds_client_custom_dialer_test.go in #7586 but some changes were not updated?

Would the plan in the next PR, once internal/prod changes were made, to delete xds_client_custom_dialer_test.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes lazy copy & paste. I removed the description, I think all we need is to tell what it extends, the rest seems obvious from reading.


// noopStatsHandler implements `stats.Handler`. It's a no-op mock handler.
type noopStatsHandler struct {
tagRPCCalled *atomic.Bool
Copy link
Contributor

Choose a reason for hiding this comment

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

What would be the reason for using *atomic.Bool instead of just atomic.Bool?
Also see below comment regarding using sync/atomic package vs channel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the way things are setup instantiates atomics in testCredsBuilder, then I saw no reason to copy. Or anything I missed?

// stats handler.
type testCredsBundle struct {
credentials.Bundle
dialerCalled *atomic.Bool
Copy link
Contributor

Choose a reason for hiding this comment

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

We switched from using chan struct{} (in xds_client_custom_dialer_test.go) to the atomic package.

Channel are used for communication between goroutines (but it can also be used as mutex/atomic synchronization). In this case, I think we should be OK as we are using it for "one-time" signaling / synchronization between goroutines. Looking at https://go.dev/ref/mem, I don't see any issues.

@easwars what would be the preferred approach here? Would there be any issues switching from channel to atomic? From Go tips/best practices, it is recommended to use channel for one-time signaling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAICT channel seems to be the obvious choice if you need to block on the event you expect. But here we can ensure expected events (both the dialer and stats handler) should have happened before we validate as we call cc.Close() first (commented). Plus for stats handler atomic simply works better as we expect multiple events but all we want to check is the presence of any.

@yousukseung
Copy link
Contributor Author

@purnesh42H @easwars kindly ping to unblock prod monitoring visibility.

@purnesh42H
Copy link
Contributor

@purnesh42H @easwars kindly ping to unblock prod monitoring visibility.

Overall it looks good to me. Few comments regarding removing some extra stuff that we have right now.

@easwars easwars added this to the 1.71 Release milestone Jan 22, 2025
@easwars easwars removed their assignment Jan 22, 2025
// data plane communication with the test backend.
cc, err := grpc.NewClient(fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(resolverBuilder))
if err != nil {
t.Fatalf("failed to dial local test server: %v", err)
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/failed/Failed

The non-capitalization of error strings don't apply to test error messages.

Copy link
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 purnesh42H and unassigned yousukseung Jan 28, 2025
@easwars
Copy link
Contributor

easwars commented Jan 28, 2025

@purnesh42H : Do you want to take another look?

@purnesh42H purnesh42H self-requested a review January 29, 2025 12:29
Copy link
Contributor

@purnesh42H purnesh42H left a comment

Choose a reason for hiding this comment

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

lgtm

@purnesh42H purnesh42H merged commit 59411f2 into grpc:master Jan 29, 2025
15 checks passed
purnesh42H pushed a commit to purnesh42H/grpc-go that referenced this pull request Jan 30, 2025
janardhanvissa pushed a commit to janardhanvissa/grpc-go that referenced this pull request Feb 13, 2025
janardhanvissa pushed a commit to janardhanvissa/grpc-go that referenced this pull request Feb 13, 2025
janardhanvissa pushed a commit to janardhanvissa/grpc-go that referenced this pull request Feb 15, 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: Internal Cleanup Refactors, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants