Skip to content

Use ThreadedResolver to honor /etc/hosts and nsswitch.conf#7776

Open
dralley wants to merge 1 commit into
pulp:mainfrom
dralley:dns-resolution
Open

Use ThreadedResolver to honor /etc/hosts and nsswitch.conf#7776
dralley wants to merge 1 commit into
pulp:mainfrom
dralley:dns-resolution

Conversation

@dralley
Copy link
Copy Markdown
Contributor

@dralley dralley commented Jun 7, 2026

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

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

See: Pull Request Walkthrough

@dralley
Copy link
Copy Markdown
Contributor Author

dralley commented Jun 7, 2026

My understanding is that we've had a number of issues with aiodns and pycares - as best I can tell we only ever depended on aiodns for purely theoretical performance reasons. But at least for syncs, you really only expect to talk to one host, or maybe a small handful, so aiodns provides no benefit.

And in this case we're being asked explicitly to follow system configurations which aiodns / c-ares does not support.

https://redhat.atlassian.net/browse/PULP-1788
https://redhat.atlassian.net/browse/SAT-45512

So, we can ditch aiodns and also ditch the pinning of pycares.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant