Skip to content

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

Merged
dralley merged 1 commit into
pulp:mainfrom
dralley:dns-resolution
Jun 8, 2026
Merged

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

Conversation

@dralley

@dralley dralley commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

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

dralley commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

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.

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 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>

@mdellweg mdellweg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transcending the problem, I love it!

Comment on lines -18 to -19
pycares<5
# older aiodns versions don't pin pycares UB, and are broken by pycares>=5

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dralley dralley merged commit 0c3fc55 into pulp:main Jun 8, 2026
13 of 14 checks passed
@dralley dralley deleted the dns-resolution branch June 8, 2026 16:36
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.

3 participants