Description
Describe the Bug
When running Puppet agent 7.28 interactively (e.g. puppet agent --test --noop
) on a host with an IPv6 address but without an IPv4 address, the run consistently hangs for over two minutes after printing Info: Loading facts
and before printing Notice: Requesting catalog from puppet.example.com:8140
.
When running on a dual stack host with both IPv4 and IPv6 addresses, there is no pause and the Notice
includes an IPv4 address in parentheses: Notice: Requesting catalog from puppet.example.com:8140 (10.0.0.1)
.
Expected Behavior
There should be no delay when running Puppet on hosts with only an IPv6 address.
Steps to Reproduce
On an IPv6 only host that uses a Puppet server with both IPv4 and IPv6 addresses, run puppet agent --test --noop
.
Environment
- Version 7.28.0
- Platform Debian Bullseye
Additional Context
The Puppet server is dual stack with routable IPv4 and IPv6 addresses. These are in DNS and can be resolved from the client system using the system resolver as normal.
This delay was not present in previous versions of Puppet. Reverting Puppet agent to 7.27.0 resolves the problem.
Looking at puppetlabs/puppet#9126, it appears that the lookup using Resolv.getaddress
is causing the delay.
Please note that all hostnames and IP addresses have been redacted and replaced in the examples below, but otherwise they are reproduced exactly as we ran them.
Using Ruby 2.7.8 on a dual stack host:
$ ruby --version; time ruby -r resolv -e 'puts Resolv.getaddress("puppet.example.com")'
ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [x86_64-linux]
10.0.0.1
real 0m0.162s
user 0m0.137s
sys 0m0.024s
Using Ruby 2.7.8 on an IPv6 only host:
$ ruby --version; time ruby -r resolv -e 'puts Resolv.getaddress("puppet.example.com")'
ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [x86_64-linux]
Traceback (most recent call last):
2: from -e:1:in `<main>'
1: from /opt/rbenv/versions/2.7.8/lib/ruby/2.7.0/resolv.rb:44:in `getaddress'
/opt/rbenv/versions/2.7.8/lib/ruby/2.7.0/resolv.rb:94:in `getaddress': no address for puppet.example.com (Resolv::ResolvError)
real 2m40.428s
user 0m0.182s
sys 0m0.056s
Using Ruby 3.2.2 on an IPv6 only host does return a result, but it's an IPv4 address which is arguably not what you would expect, so I suspect this issue is less visible in Puppet 8.x but may represent a related but slightly different bug:
$ ruby --version; time ruby -r resolv -e 'puts Resolv.getaddress("puppet.example.com")'
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
10.0.0.1
real 0m0.191s
user 0m0.152s
sys 0m0.039s
Noting that if you use the Resolv
gem under Ruby 2.7.8 rather than the builtin, this works as per 3.2.2 which would seem to be what you'd expect:
$ cat Gemfile; ruby --version; time ruby -r 'bundler/setup' -r resolv -e 'puts Resolv.getaddress("puppet.example.com")'
source "https://rubygems.org"
gem "resolv", "0.3.0"
ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [x86_64-linux]
10.0.0.1
real 0m0.328s
user 0m0.296s
sys 0m0.031s