You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't send AAAA DNS request when domain resolved to IPv4 address (#153)
* Don't patch out whole _connect body in test_AbstractTransport
It should raise test coverage level for the method.
* tests: check that if socket.connect raises, it bubbles up
* tests: cover _connect behavior when multiple entries are found
_connect should continue to iterate through entries returned by
getaddrinfo until it succeeds, or until it depletes the list, at which
point it raises socket.error.
* Don't send AAAA DNS request when domain resolved to IPv4 address
There is no need to send both A and AAAA requests when connecting to a
host since we are interested in a single address only. So if the host
resolves into IPv4 address, we can skip request for AAAA since it will
not be used anyway.
This sounds like a minor optimization, but it comes as a huge win in
case where DNS resolver is not configured for the requested host name,
but the name is listed in /etc/hosts with a IPv4 address. In this case,
resolution is very quick (the file is local, so no DNS request is sent),
except for the fact that we still ask for AAAA record for the host name.
A misconfigured DNS resolver can take time until it will time out the
request (30 seconds is a common length for Linux), which is an
unnecessary delay.
This exact situation hit OpenStack TripleO CI where DNS was not
configured, but resolution is implemented via /etc/hosts file which did
not include IPv6 entries.
OpenStack bug: https://bugs.launchpad.net/neutron/+bug/1696094
* tests: cover recover logic when getaddrinfo raises gaierror
* tests: check NotImplementedError from set_cloexec in _connect
If it's raised, we do nothing.
* Added some more comments in _connect explaining the logic
The logic became a bit hard to follow, so added a bunch of comments
trying to explain the rationale behind the complexity, as well as give
key for intent of specific code blocks.
* _connect: made the socket error message more descriptive
Suggest it's a DNS resolution issue, not a generic connectivity problem.
* Replace an unused variable with _
* _connect: extracted len() results into separate variables
0 commit comments