Use ThreadedResolver to honor /etc/hosts and nsswitch.conf#7776
Conversation
|
My understanding is that we've had a number of issues with Original issue: https://pulp.plan.io/issues/6190 I don't think we ever measured a practical benefit nor would one really be expected. But in this case we're being asked explicitly to follow system configurations which https://redhat.atlassian.net/browse/PULP-1788 So, we can ditch |
Pulpcore depended on aiodns, which causes aiohttp to default to AsyncResolver (c-ares) for DNS resolution. c-ares is a DNS client that speaks the wire protocol directly -- it does not go through glibc's getaddrinfo() and therefore ignores nsswitch.conf and /etc/hosts. This causes sync to fail when the remote hostname is only resolvable via /etc/hosts or other non-DNS nsswitch sources. Explicitly use aiohttp.resolver.ThreadedResolver, which wraps socket.getaddrinfo() in a thread pool. Since getaddrinfo() uses the system resolver, it respects nsswitch.conf ordering and reads /etc/hosts when configured. This is expected to have negligible impact as sync hits a limited number of hosts, and DNS resolution happens once-per-host. Since we now bypass c-ares entirely, drop the aiodns dependency and the related pycares version constraint from CI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mdellweg
left a comment
There was a problem hiding this comment.
Transcending the problem, I love it!
| pycares<5 | ||
| # older aiodns versions don't pin pycares UB, and are broken by pycares>=5 |
There was a problem hiding this comment.
This will come in via the plugin template, but also it is not-a-problem, since constraints will not pull a package, but just restrict it's version range when selected elsewhere.
Pulpcore depended on aiodns, which causes aiohttp to default to AsyncResolver (c-ares) for DNS resolution. c-ares is a DNS client that speaks the wire protocol directly -- it does not go through glibc's getaddrinfo() and therefore ignores nsswitch.conf and /etc/hosts. This causes sync to fail when the remote hostname is only resolvable via /etc/hosts or other non-DNS nsswitch sources.
Explicitly use aiohttp.resolver.ThreadedResolver, which wraps socket.getaddrinfo() in a thread pool. Since getaddrinfo() uses the system resolver, it respects nsswitch.conf ordering and reads /etc/hosts when configured.
The performance difference is negligible for Pulp's use case: DNS resolution happens once per host (aiohttp caches resolved addresses on the connector), and syncs typically talk to a small number of distinct hosts.
Since we now bypass c-ares entirely, drop the aiodns dependency and the related pycares version constraint from CI.
📜 Checklist
See: Pull Request Walkthrough