Skip to content

Conversation

@eshitachandwani
Copy link
Member

@eshitachandwani eshitachandwani commented Sep 27, 2025

Fixes: #8607

RELEASE NOTES:

  • Fixes a bug where default port 443 was not being added to addresses without port being sent to proxy.
  • Adds a new environment variable GRPC_EXPERIMENTAL_ENABLE_DEFAULT_PORT_FOR_PROXY_TARGET for adding a default port to addresses being sent to proxy which is set by default.

@codecov
Copy link

codecov bot commented Sep 28, 2025

Codecov Report

❌ Patch coverage is 56.25000% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.50%. Comparing base (bb71072) to head (a941615).
⚠️ Report is 25 commits behind head on master.

Files with missing lines Patch % Lines
.../resolver/delegatingresolver/delegatingresolver.go 62.79% 13 Missing and 3 partials ⚠️
internal/envconfig/envconfig.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8613      +/-   ##
==========================================
- Coverage   82.00%   81.50%   -0.50%     
==========================================
  Files         415      415              
  Lines       40697    40873     +176     
==========================================
- Hits        33372    33312      -60     
- Misses       5937     6139     +202     
- Partials     1388     1422      +34     
Files with missing lines Coverage Δ
internal/envconfig/envconfig.go 55.55% <0.00%> (-44.45%) ⬇️
.../resolver/delegatingresolver/delegatingresolver.go 55.82% <62.79%> (-30.60%) ⬇️

... and 48 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines 114 to 117
addr, err := parseTarget(target.Endpoint())
if err != nil {
return nil, fmt.Errorf("delegating_resolver: invalid target address %q: %v", target.Endpoint(), err)
}
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 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.

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

My thinking was we should do the basic check and add localhost for all addresses if no host is present irrespective of the resolver being used, but adding default port 443 is only for DNS resolver with target resolution disabled. And the first part should not be behind the flag , but only 2nd part should. That is my understanding, let me know if I am missing something.

Copy link
Contributor

Choose a reason for hiding this comment

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

From my understanding, only the DNS resolver was defaulting the hostname to localhost. Applying this logic to all resolvers would be a behaviour change which could potentially break some custom resolver that isn't expecting this. I would recommend avoiding such a change to be safe.


Also, since we're providing a env variable flag, we should ensure the flag can revert all (if not most) changes in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.

name string
target string
wantConnectAddress string
wantErrorSubstring string
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

I already have a seperate test for it : TestDelegatingResolverEnvVarForDefaultPortDisable

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we combine the tests using an additional param? That should help reduce duplicate code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

disableDefaultPortEnvVar bool
}{
{
name: "no port in target",
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Subtest names still have spaces which make them hard to search for when you get here from a failing test run.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ohhh... I misunderstood some parts. Got it!

Copy link
Contributor

Choose a reason for hiding this comment

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

I still see subtest names with spaces. The gotip that I linked to recommends that we not have spaces in them, but have underscores. That way, when you have TestFoo with a subtest name subtest_name, it will show up in the output as TestFoo/subtest_name and you can directly copy-paste and search in the code. But if you have TestFoo with a subtest name subtest name, it will show up in the output as TestFoo/subtest_name, and copy-paste will not work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

}
overrideTestHTTPSProxy(t, envProxyAddr)

targetResolver := manual.NewBuilderWithScheme("dns")
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you have to unregister the original dns resolver and re-register it at the end of the test, for this test to not affect other tests?

targetResolver := manual.NewBuilderWithScheme("dns")
target := targetResolver.Scheme() + ":///" + test.target
// Set up a manual DNS resolver to control the proxy address resolution.
proxyResolver, proxyResolverBuilt := setupDNS(t)
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see that this helper does re-register the original dns resolver. But maybe this section can still be a little more explicit/readable etc. I'm not able to think of the exact way to make this better right now.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is what we had earlier too..in the tests.

@easwars easwars assigned eshitachandwani and unassigned arjan-bal Oct 7, 2025
@easwars easwars assigned eshitachandwani and unassigned easwars and arjan-bal Oct 9, 2025
t.Fatal("Context timed out when waiting for a state update from the delegating resolver")
// Tests the creation of a delegating resolver when a proxy is configured. It
// verifies correct error handling for invalid targets.
func (s) TestDelegatingResolverwithDNSAndProxyWithNoTargetResolutionWithErrorTargets(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Lol

I think you are going to win the longest test name award in our codebase :P :P

Maybe we can shorten these some other time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried to maybe shorten a bit .

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried to change it be a little shorter..Maybe?

@easwars easwars assigned eshitachandwani and unassigned easwars and arjan-bal Oct 13, 2025
@eshitachandwani eshitachandwani merged commit f28fbeb into grpc:master Oct 14, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTPS_PROXY support issues non-compliant CONNECT requests

3 participants