-
Notifications
You must be signed in to change notification settings - Fork 4.6k
delegatingresolver: add default port to addresses #8613
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8613 +/- ##
==========================================
+ Coverage 82.00% 82.03% +0.03%
==========================================
Files 415 415
Lines 40697 40729 +32
==========================================
+ Hits 33372 33414 +42
+ Misses 5937 5925 -12
- Partials 1388 1390 +2
🚀 New features to boost your workflow:
|
// AddDefaultPort is set if the resolver should add the default port when | ||
// the target address doesn't contain a port. We will add the default port | ||
// 443 for default scheme. | ||
AddDefaultPort = boolFromEnv("GRPC_EXPERIMENTAL_RESOLVER_ADD_DEFAULT_PORT", true) |
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.
The name and the comment for this flag need to be more precise. Notably, this flag controls the addition of the default port only when all of the following conditions are met:
- A connect proxy is being used.
- Target resolution is disabled.
- DNS resolver is being used.
addr, err := parseTarget(target.Endpoint()) | ||
if err != nil { | ||
return nil, fmt.Errorf("delegating_resolver: invalid target address %q: %v", target.Endpoint(), err) | ||
} |
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 we should guard this call to parseTarget
behind the feature flag since it can potentially lead to new/different failures after this PR is merged.
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.
We can have only one block guarded by the feature flag if we instead do the following:
addr := target.Endpoint()
if target.URL.Scheme == "dns" && !targetResolutionEnabled && envconfig.AddDefaultPort {
addr, err = parseTarget(target.Endpoint(), defaultPort)
if err != nil {
// return some error
}
}
This way we can use the parseTarget
function from the dns resolver without any modifications.
// resolution should be handled by the proxy, not the client. Therefore, we | ||
// bypass the target resolver and store the unresolved target address. | ||
if target.URL.Scheme == "dns" && !targetResolutionEnabled { | ||
addr := target.Endpoint() |
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 should be using the addr
declared above, the one with the default hostname?
// verifies that the addresses returned by the delegating resolver include the | ||
// proxy resolver's addresses, with the unresolved target URI as an attribute | ||
// of the proxy address. | ||
// TestDelegatingResolverWithProxy tests the creation of a delegating resolver |
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.
The name of the test function doesn't match in the comment. It can be replaced with a shorter "Tests".
name string | ||
target string | ||
wantConnectAddress string | ||
wantErrorSubstring 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.
Can you add another test param for the env variable and tests cases for the env variable being disabled?
t.Fatalf("Delegating resolver created, want error containing %q", test.wantErrorSubstring) | ||
} | ||
if !strings.Contains(err.Error(), test.wantErrorSubstring) { | ||
t.Fatalf("Delegating resolver failed with error %q, want error containing %q", err.Error(), test.wantErrorSubstring) |
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 used %v
to format errors.
if !strings.Contains(err.Error(), test.wantErrorSubstring) { | ||
t.Fatalf("Delegating resolver failed with error %q, want error containing %q", err.Error(), test.wantErrorSubstring) | ||
} | ||
// Expected error was found, so the test case for this part is done. |
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: I think the comment here is unnecessary, the return
statement is self-explanatory.
Fixes: #8607
RELEASE NOTES:
GRPC_EXPERIMENTAL_RESOLVER_ADD_DEFAULT_PORT
for adding a default port to addresses being sent to proxy which is set by default.