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: introduce generic xds clients common configs #8024

Merged
merged 11 commits into from
Jan 31, 2025

Conversation

purnesh42H
Copy link
Contributor

@purnesh42H purnesh42H commented Jan 21, 2025

This is the first part of generic xds clients to be usable outside of grpc. This change is adding the common configurations that are required to create xDS and LRS clients for communicating to an xDS management server.

POC
Internal Design

RELEASE NOTES: None

@purnesh42H purnesh42H force-pushed the generic-xds-client-1-interface branch 3 times, most recently from b45e034 to 27adf6e Compare January 21, 2025 04:54
@purnesh42H purnesh42H requested review from dfawley and easwars January 21, 2025 04:55
Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 93.18182% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.37%. Comparing base (2517a46) to head (e191ba1).
Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
xds/internal/clients/config.go 93.18% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8024      +/-   ##
==========================================
+ Coverage   82.24%   82.37%   +0.13%     
==========================================
  Files         382      388       +6     
  Lines       38711    39062     +351     
==========================================
+ Hits        31836    32179     +343     
- Misses       5555     5565      +10     
+ Partials     1320     1318       -2     
Files with missing lines Coverage Δ
xds/internal/clients/config.go 93.18% <93.18%> (ø)

... and 62 files with indirect coverage changes

@purnesh42H purnesh42H added Type: Feature New features or improvements in behavior Area: xDS Includes everything xDS related, including LB policies used with xDS. labels Jan 21, 2025
@purnesh42H purnesh42H added this to the 1.71 Release milestone Jan 21, 2025
@purnesh42H purnesh42H force-pushed the generic-xds-client-1-interface branch 2 times, most recently from c4fd324 to 88c7d68 Compare January 21, 2025 17:48
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
@purnesh42H purnesh42H requested a review from zasweq January 22, 2025 04:36
xds/clients/README Outdated Show resolved Hide resolved
xds/clients/README Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/README Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/transport_builder.go Outdated Show resolved Hide resolved
xds/clients/transport_builder.go Outdated Show resolved Hide resolved
xds/clients/transport_builder.go Outdated Show resolved Hide resolved
xds/clients/transport_builder.go Outdated Show resolved Hide resolved
@easwars easwars assigned purnesh42H and unassigned easwars and dfawley Jan 22, 2025
@purnesh42H purnesh42H force-pushed the generic-xds-client-1-interface branch 2 times, most recently from 4e9e733 to ca5b27d Compare January 23, 2025 08:40
@purnesh42H purnesh42H requested a review from easwars January 23, 2025 09:20
@purnesh42H purnesh42H assigned easwars and dfawley and unassigned purnesh42H Jan 23, 2025
xds/clients/README Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/config.go Outdated Show resolved Hide resolved
xds/clients/transport_builder.go Outdated Show resolved Hide resolved
xds/clients/transport_builder.go Outdated Show resolved Hide resolved
xds/clients/transport_builder.go Outdated Show resolved Hide resolved
xds/clients/transport_builder.go Outdated Show resolved Hide resolved
xds/clients/transport_builder.go Outdated Show resolved Hide resolved
@easwars easwars removed their assignment Jan 23, 2025
@purnesh42H purnesh42H changed the title xds: introduce generic xds client common configs xds: introduce generic xds clients common configs Jan 27, 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.

Changes look good to me.

What is the plan for tests? I don't see any tests in this PR.

case sc.IgnoreResourceDeletion != other.IgnoreResourceDeletion:
return false
}
if ex, ok := sc.Extensions.(interface{ Equal(any) bool }); ok && ex.Equal(other.Extensions) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: we should probably make a mention of this Equal method in the docstring for the Extensions field. That way, users know that they need to implement this.

Also, looks like we are missing tests for the Equal method. Codecov is complaining. I'm OK if you want to add these in a follow-up PR. But if you are doing that, please ensure that you either file an issue or send that PR right away so that we don't forget about it. Thanks.

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 have mentioned the Equal method in the docstring

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 have added tests for both Locality and ServerConfig Equal

@easwars easwars assigned dfawley and unassigned easwars Jan 28, 2025
@purnesh42H purnesh42H force-pushed the generic-xds-client-1-interface branch from d993711 to 8375a37 Compare January 28, 2025 10:14
@purnesh42H
Copy link
Contributor Author

purnesh42H commented Jan 28, 2025

Changes look good to me.

What is the plan for tests? I don't see any tests in this PR.

I have added the test for Equal Methods, Locality's empty check and Node's ToProto. Initially i was thinking that they would get covered through implementation code and e2e tests but adding here is better to not discover something wrong later.

@purnesh42H purnesh42H requested a review from easwars January 28, 2025 10:17
@purnesh42H purnesh42H force-pushed the generic-xds-client-1-interface branch from 8375a37 to 377e7d1 Compare January 28, 2025 16:18
Copy link
Member

Choose a reason for hiding this comment

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

Should we put this in internal during early development and move it later, when we're ready for a user?

Copy link
Contributor Author

@purnesh42H purnesh42H Jan 29, 2025

Choose a reason for hiding this comment

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

I have moved to internal. I have kept the README but let me know if you want to remove it for now.

case sc.IgnoreResourceDeletion != other.IgnoreResourceDeletion:
return false
}
if sc.Extensions == nil && other.Extensions == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Merge with the switch above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That won't be correct right? Switch case is for early return which happens in case of false. For true, we need to ensure all fields are equal so we check Extensions only after all fields are found to be equal. Like if we move Extensions nil check to switch, the code look ambiguous for condition when say URIs are different and both Extensions are nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Though i have two more test cases, when either of server config extensions are nil

Comment on lines 153 to 156
// ClientFeatures is a list of xDS features supported by this client.
// These features are set within the xDS client, but may be overridden only
// for testing purposes.
ClientFeatures []string
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to export this?

Copy link
Contributor Author

@purnesh42H purnesh42H Jan 29, 2025

Choose a reason for hiding this comment

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

So, this field is populated by the xDS client which will be in a separate package xdsclient. So xDS client needs to access it. That's why we need to export or we need to provide a method to populate it. What is the best way?

Copy link
Member

Choose a reason for hiding this comment

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

I would think the best would be an internal method that is able to set this unexported field.

Either way, unexport it and we can work out the best way to set it when we need to set it. Things should not exported because of testing or internal usage.

Similar for ToProto. This isn't something that users will call, so it shouldn't be exported. Maybe that's how this shakes out....ToProto becomes a function inside xdsclient and that is where we set the client features.

Copy link
Contributor Author

@purnesh42H purnesh42H Jan 29, 2025

Choose a reason for hiding this comment

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

I have unexported toProto and clientFeatures. Another way I can think is we can unexport node and provide a function to create new node which sets clientFeatures and have an exported method to get Node in proto form because that's what channel needs. We can discuss more during implementation.

@purnesh42H purnesh42H force-pushed the generic-xds-client-1-interface branch from 672a5e3 to db86d0b Compare January 29, 2025 07:07
@purnesh42H purnesh42H requested a review from dfawley January 29, 2025 07:11
@easwars easwars removed their assignment Jan 29, 2025
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

Before we start implementing anything, we should go over the proposed API, as viewed through godoc, in a meeting. There's already a few things that are leaking into the external API that are implementation details that I've found, so we should make sure there aren't more before we get too far down the road.

Comment on lines 199 to 205
// IsEmpty reports whether l is considered empty.
func (l Locality) IsEmpty() bool {
return l.Equal(Locality{})
}

// Equal returns true if l and other are considered equal.
func (l Locality) Equal(other Locality) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Why are these exported? Users shouldn't need them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same reason because xdsclient implementation needs. Unexported for now.

}

// Equal returns true if sc and other are considered equal.
func (sc *ServerConfig) Equal(other *ServerConfig) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same reason because xdsclient implementation needs. Unexported for now.

Copy link
Member

Choose a reason for hiding this comment

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

Does this not need to be README.md? But can we just delete it now that it's internal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted for now

@dfawley dfawley assigned purnesh42H and unassigned dfawley Jan 30, 2025
@purnesh42H
Copy link
Contributor Author

purnesh42H commented Jan 31, 2025

Before we start implementing anything, we should go over the proposed API, as viewed through godoc, in a meeting. There's already a few things that are leaking into the external API that are implementation details that I've found, so we should make sure there aren't more before we get too far down the road.

I have unexported all the methods of structs including isEmpty and equal. All these are needed by xds client implementation.

Yeah we can go over the exported stuff and we also need to decide how will xdsclient access these struct methods

@purnesh42H purnesh42H force-pushed the generic-xds-client-1-interface branch from 30aac28 to e191ba1 Compare January 31, 2025 10:20
@purnesh42H purnesh42H merged commit 7dbf12e into grpc:master Jan 31, 2025
15 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.

4 participants