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

resolver: replace resolver.Target.Endpoint field with Endpoint() method #5852

Merged

Conversation

kylejb
Copy link
Contributor

@kylejb kylejb commented Dec 9, 2022

Fixes #5796

Summary of Changes

  • Remove deprecated field: resolver.Target.Endpoint. (BREAKING CHANGE)
  • Create receiver function for resolver.Target called Endpoint() that returns either URL.Path or URL.Opaque (latter is used as endpoint, if former is empty).
  • Replace usage of resolver.Target.Endpoint to resolver.Target.Endpoint().
  • Fix tests like "internal/dns_resolver_test" by setting values for resolver.Target.URL with testutils.MustParseURL to support removal of resolver.Target.Endpoint.

RELEASE NOTES:

  • resolver: deprecated field resolver.Target.Endpoint has been removed and replaced by resolver.Target.Endpoint().

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 9, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: kylejb / name: Kyle J. Burda (00aad9b)

@kylejb kylejb force-pushed the refactor/5796-resolver-target-endpoint branch from 00aad9b to 345111e Compare December 9, 2022 03:45
@kylejb kylejb force-pushed the refactor/5796-resolver-target-endpoint branch 2 times, most recently from 6f04842 to c87606b Compare December 9, 2022 04:47
@easwars easwars self-assigned this Dec 13, 2022
@easwars easwars added the Type: Internal Cleanup Refactors, etc label Dec 13, 2022
@easwars easwars added this to the 1.52 Release milestone Dec 13, 2022
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.

Thank you very much for your changes.

resolver/resolver.go Outdated Show resolved Hide resolved
internal/resolver/dns/dns_resolver_test.go Outdated Show resolved Hide resolved
internal/testutils/parse_url.go Outdated Show resolved Hide resolved
@kylejb kylejb requested a review from easwars December 15, 2022 23:39
easwars
easwars previously approved these changes Dec 15, 2022
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 except the one nit.

internal/testutils/parse_url.go Outdated Show resolved Hide resolved
@easwars easwars self-requested a review January 19, 2023 23:03
@easwars easwars dismissed their stale review January 19, 2023 23:03

Approach has changed now.

@easwars easwars removed their assignment Jan 19, 2023
@easwars easwars removed their request for review January 19, 2023 23:04
@kylejb kylejb force-pushed the refactor/5796-resolver-target-endpoint branch 3 times, most recently from 5234364 to 685552f Compare January 21, 2023 19:58
@@ -614,7 +615,7 @@ func (s) TestResourceResolverEDSAndDNS(t *testing.T) {
}
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 != "" {
Copy link
Contributor Author

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.

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 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.

Copy link
Contributor Author

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.

// URL contains the parsed dial target with an optional default scheme added
// to it if the original dial target contained no scheme or contained an
// unregistered scheme. Any query params specified in the original dial
// target can be accessed from here.
URL url.URL
}

// Endpoint retrieves endpoint without leading "/" from either `URL.Path`
// or `URL.Opaque`. The latter is set when the former is empty.
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/The latter is set when the former is empty/The latter is used when the former is empty/

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!

"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"
Copy link
Contributor

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.

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!

Thanks for the explanation. Makes sense.

@@ -614,7 +615,7 @@ func (s) TestResourceResolverEDSAndDNS(t *testing.T) {
}
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 != "" {
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 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
@kylejb kylejb force-pushed the refactor/5796-resolver-target-endpoint branch from 685552f to 779f9c5 Compare January 23, 2023 22:26
@kylejb kylejb requested a review from easwars January 23, 2023 22:29
@dfawley dfawley changed the title cleanup: usages of resolver.Target.Endpoint resolver: replace resolver.Target.Endpoint field with Endpoint() method Jan 23, 2023
@dfawley dfawley added Type: API Change Breaking API changes (experimental APIs only!) and removed Type: Internal Cleanup Refactors, etc labels Jan 23, 2023
@arvindbr8 arvindbr8 assigned easwars and unassigned kylejb Jan 24, 2023
@easwars easwars merged commit 3930549 into grpc:master Jan 24, 2023
1 check passed
@kylejb kylejb deleted the refactor/5796-resolver-target-endpoint branch January 24, 2023 20:24
@kylejb kylejb mentioned this pull request Jan 24, 2023
1 task
mcpherrinm added a commit to mcpherrinm/boulder that referenced this pull request Mar 9, 2023
This is based on the upstream breaking-change in v1.53
grpc/grpc-go#5852
aarongable pushed a commit to letsencrypt/boulder that referenced this pull request Mar 15, 2023
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
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: API Change Breaking API changes (experimental APIs only!)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cleanup usages of resolver.Target.Endpoint
4 participants