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

DNS resolving with timeout

Open and1truong opened this issue 5 months ago • 5 comments

Currently, the DNS resolver does not have a timeout mechanism for DNS resolution. In some edge cases, where the DNS server is slow to respond, this can lead to stale records being used, resulting in failed connections or other issues.

This pull request adds a configurable timeout for DNS resolution, which can be set by the user to a value that suits their needs. The default value is set to 5 seconds, which should be sufficient for most cases. If the DNS server does not respond within the specified time, the resolver will cancel the request and move on to the next available server.

Please review and let me know if you have any questions or concerns.

Thanks!

RELEASE NOTES:

  • resolver/dns: add SetResolvingTimeout to allow configuring the DNS resolver's timeout globally.

and1truong avatar Jan 11 '24 01:01 and1truong

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: and1truong / name: Hong Truong (8862fe5b21ee157d35b392d1c96e2757026220e6, d9dcc72131287706d8db93a5179577deb121f97d, 5e45d0defed1452816841d5324cfae1f76eb02ae, a0ce76b8da6dea072d12a58513ca50f5e8a7eb87, 40a85c3045184b79e6cfacd01c229f227e5c4c20, 00ba49336c3a1a34cb2402283df2572cc864302c)

Codecov Report

Merging #6917 (5e45d0d) into master (03e76b3) will decrease coverage by 1.32%. Report is 27 commits behind head on master. The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6917      +/-   ##
==========================================
- Coverage   83.70%   82.38%   -1.32%     
==========================================
  Files         288      296       +8     
  Lines       30921    31468     +547     
==========================================
+ Hits        25883    25926      +43     
- Misses       3976     4475     +499     
- Partials     1062     1067       +5     
Files Coverage Δ
internal/resolver/dns/dns_resolver.go 89.31% <100.00%> (+0.08%) :arrow_up:
resolver/dns/dns_resolver.go 50.00% <100.00%> (+50.00%) :arrow_up:

... and 37 files with indirect coverage changes

codecov[bot] avatar Jan 11 '24 01:01 codecov[bot]

Hi @and1truong,

Such a wide-sweeping change would require cross-language agreement for adding this.

Instead, maybe you can add a global in the resolver/dns package to control this (which would be set globally at initialization time)? This is equivalent to what gRPC-Java has for this kind of thing.

dfawley avatar Jan 25 '24 17:01 dfawley

This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed.

github-actions[bot] avatar Jan 31 '24 18:01 github-actions[bot]

Thanks for comment. I will start working on this next week.

and1truong avatar Feb 02 '24 14:02 and1truong

This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed.

github-actions[bot] avatar Feb 21 '24 20:02 github-actions[bot]

@and1truong -- let us know if this is ready for another review

arvindbr8 avatar Feb 29 '24 19:02 arvindbr8

@arvindbr8 I pushed the changes recommended by @dfawley.

and1truong avatar Feb 29 '24 19:02 and1truong

okay, I'll request @dfawley to take another look at this

arvindbr8 avatar Feb 29 '24 19:02 arvindbr8

Thanks for the PR @and1truong. We look forward to seeing your next PR.

arvindbr8 avatar Mar 05 '24 23:03 arvindbr8