-
Notifications
You must be signed in to change notification settings - Fork 4.6k
resolver: replace resolver.Target.Endpoint field with Endpoint() method #5852
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
resolver: replace resolver.Target.Endpoint field with Endpoint() method #5852
Conversation
|
|
00aad9b to
345111e
Compare
6f04842 to
c87606b
Compare
easwars
left a comment
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.
Thank you very much for your changes.
c87606b to
43c8130
Compare
easwars
left a comment
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 except the one nit.
676cfc8 to
978441f
Compare
5234364 to
685552f
Compare
| select { | ||
| case target := <-dnsTargetCh: | ||
| if diff := cmp.Diff(target, resolver.Target{Scheme: "dns", Endpoint: testDNSTarget}); diff != "" { | ||
| if diff := cmp.Diff(target, resolver.Target{Scheme: "dns", URL: *testutils.MustParseURL(testDNSTarget)}); diff != "" { |
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.
@easwars, do we need to manually prepend scheme here (e.g., "dns:///" + testDNSTarget)? Any guidance as to when it would be necessary to do so and why it must be done manually?
FYI - there are a handful of lines in this file and another where I should potentially prepend scheme to target. Although not doing so does not seem to cause any errors in testing, I wanted to flag this inconsistency.
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 think url.Parse() doesn't like a URL without a scheme, because there is no default scheme as we have in grpc. So, wherever we need to pass a value directly to url.Parse(), the value would need to have a scheme.
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.
Ah, thanks! I went ahead and added scheme to remain consistent.
Let me know if you'd like me to revert that. Interestingly, tests do not appear to be affected by that decision.
resolver/resolver.go
Outdated
| } | ||
|
|
||
| // Endpoint retrieves endpoint without leading "/" from either `URL.Path` | ||
| // or `URL.Opaque`. The latter is set when the former is empty. |
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: s/The latter is set when the former is empty/The latter is used when the former is empty/
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.
Done!
| "google.golang.org/grpc/resolver" | ||
| "google.golang.org/grpc/resolver/manual" | ||
| "google.golang.org/grpc/xds/internal/testutils" | ||
| testutilsXDS "google.golang.org/grpc/xds/internal/testutils" |
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.
Could you please rename the import as xdstestutils instead. We have done that in other places, and doing the same here wold stay consistent with existing usages. 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.
Done!
Thanks for the explanation. Makes sense.
| select { | ||
| case target := <-dnsTargetCh: | ||
| if diff := cmp.Diff(target, resolver.Target{Scheme: "dns", Endpoint: testDNSTarget}); diff != "" { | ||
| if diff := cmp.Diff(target, resolver.Target{Scheme: "dns", URL: *testutils.MustParseURL(testDNSTarget)}); diff != "" { |
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 think url.Parse() doesn't like a URL without a scheme, because there is no default scheme as we have in grpc. So, wherever we need to pass a value directly to url.Parse(), the value would need to have a scheme.
* feat(resolver): replace with Endpoint() * chore(resolver): update documentation for Endpoint() * fix(dns_resolver_test): add escape for percent char
685552f to
779f9c5
Compare
Upgrade grpc to v1.53.0, as preparation for introducing OpenTelemetry, which depends on that grpc version. Two changes to our own code were necessitated by upstream changes: 1. Add a stub implementation of GetOrBuildProducer: this was added to the balancer.SubConn interface by grpc v1.51.0 2. Change use of Endpoint field to Endpoint() method: the field was removed and replaced by a method in grpc/grpc-go#5852. This also means that our tests can't set the .Endpoint field, so the tests are updated to use the .URL field instead, and a helper has been added to make that easy. Part of #6361
Fixes #5796
Summary of Changes
resolver.Target.Endpoint. (BREAKING CHANGE)resolver.TargetcalledEndpoint()that returns eitherURL.PathorURL.Opaque(latter is used as endpoint, if former is empty).resolver.Target.Endpointtoresolver.Target.Endpoint().resolver.Target.URLwithtestutils.MustParseURLto support removal ofresolver.Target.Endpoint.RELEASE NOTES:
resolver.Target.Endpointhas been removed and replaced byresolver.Target.Endpoint().