grpc-go
grpc-go copied to clipboard
DNS resolving with timeout
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.
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 is100.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: |
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.
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.
Thanks for comment. I will start working on this next week.
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.
@and1truong -- let us know if this is ready for another review
@arvindbr8 I pushed the changes recommended by @dfawley.
okay, I'll request @dfawley to take another look at this
Thanks for the PR @and1truong. We look forward to seeing your next PR.