grpc-go icon indicating copy to clipboard operation
grpc-go copied to clipboard

dns: add environment variable to disable TXT lookups in DNS resolver

Open dfawley opened this issue 7 months ago • 3 comments

Fixes #8356

Note that there is no way to force TXT lookups happen for a specific channel. If someone requests this feature, we can consider it at that time, but I don't imagine there will be demand for it.

RELEASE NOTES:

  • dns: add an environment variable (GRPC_ENABLE_TXT_SERVICE_CONFIG) to provide a way to disable TXT lookups in the DNS resolver (by setting it to false). By default, TXT lookups are enabled, as they were before this change.

dfawley avatar Jun 02 '25 21:06 dfawley

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 82.32%. Comparing base (dd718e4) to head (ac7fef6). Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8377      +/-   ##
==========================================
+ Coverage   82.27%   82.32%   +0.04%     
==========================================
  Files         414      414              
  Lines       40424    40424              
==========================================
+ Hits        33259    33279      +20     
+ Misses       5795     5781      -14     
+ Partials     1370     1364       -6     
Files with missing lines Coverage Δ
internal/envconfig/envconfig.go 100.00% <ø> (ø)
internal/resolver/dns/dns_resolver.go 88.34% <100.00%> (ø)

... and 18 files with indirect coverage changes

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

codecov[bot] avatar Jun 02 '25 21:06 codecov[bot]

Would it make sense to rename GRPC_ENABLE_TXT_SERVICE_CONFIG to something like GRPC_DISABLE_TXT_SERVICE_CONFIG since the default behavior is that TXT lookups are enabled? Just thinking it might better reflect the default behavior and make it clearer when someone wants to opt out.

eshitachandwani avatar Jun 04 '25 05:06 eshitachandwani

Would it make sense to rename GRPC_ENABLE_TXT_SERVICE_CONFIG to something like GRPC_DISABLE_TXT_SERVICE_CONFIG since the default behavior is that TXT lookups are enabled? Just thinking it might better reflect the default behavior and make it clearer when someone wants to opt out.

In most cases, we should try to have boolean variables indicate the positive case. This makes it easier to read the the code when they're used in more complex boolean expressions. See this readability tip.

arjan-bal avatar Jun 04 '25 14:06 arjan-bal

Can you please add a test for verifying that txt lookups are disabled when the env var is set? It should be possible to add a new boolean param to the existing test which controls setting of envconfig.EnableTXTServiceConfig.

Yes, I meant to do this but forgot. Done.

dfawley avatar Jun 30 '25 20:06 dfawley