-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
xds: introduce generic xds clients common configs #8024
Conversation
b45e034
to
27adf6e
Compare
Codecov ReportAttention: Patch coverage is
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
|
c4fd324
to
88c7d68
Compare
4e9e733
to
ca5b27d
Compare
There was a problem hiding this 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.
xds/clients/config.go
Outdated
case sc.IgnoreResourceDeletion != other.IgnoreResourceDeletion: | ||
return false | ||
} | ||
if ex, ok := sc.Extensions.(interface{ Equal(any) bool }); ok && ex.Equal(other.Extensions) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
d993711
to
8375a37
Compare
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. |
8375a37
to
377e7d1
Compare
xds/clients/README
Outdated
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
xds/clients/config.go
Outdated
case sc.IgnoreResourceDeletion != other.IgnoreResourceDeletion: | ||
return false | ||
} | ||
if sc.Extensions == nil && other.Extensions == nil { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
xds/clients/config.go
Outdated
// 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
672a5e3
to
db86d0b
Compare
There was a problem hiding this 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.
xds/internal/clients/config.go
Outdated
// 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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
xds/internal/clients/config.go
Outdated
} | ||
|
||
// Equal returns true if sc and other are considered equal. | ||
func (sc *ServerConfig) Equal(other *ServerConfig) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
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.
xds/internal/clients/README
Outdated
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted for now
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 |
30aac28
to
e191ba1
Compare
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