Subject: | Strange behaviour in Net::DNS::Resolver->search around NOERROR results with no records |
Allow me to prefix this by saying that I'm not a Perl programmer so apologise if I've screwed up terminology etc.
After a bit of investigation in https://phabricator.wikimedia.org/T153468, I believe the following when Net::DNS::Resolver->search gets a NOERROR result with no records:
* if there is no trailing full stop in the domain, it tries adding the search domain(s) to the end, leading to NXDOMAIN.
* if there is a trailing full stop in the domain, it returns undef, when it should give a Net::DNS::Packet=HASH with an empty ->answer.
Here's some examples. You should be able to get these records from labs-ns0.wikimedia.org while outside our network.
krenair@deployment-deploy01:~$ perl -e "require Net::DNS; my \$resolver = new Net::DNS::Resolver; \$resolver->search('deployment-prometheus01.deployment-prep.eqiad.wmflabs', 'A'); print \$resolver->errorstring"
NOERROR
krenair@deployment-deploy01:~$ perl -e "require Net::DNS; my \$resolver = new Net::DNS::Resolver; \$resolver->search('deployment-prometheus01.deployment-prep.eqiad.wmflabs', 'AAAA'); print \$resolver->errorstring"
NXDOMAIN
krenair@deployment-deploy01:~$ perl -e "require Net::DNS; my \$resolver = new Net::DNS::Resolver(debug => 1); \$resolver->search('deployment-prometheus01.deployment-prep.eqiad.wmflabs', 'AAAA'); print \$resolver->errorstring"
;; search( deployment-prometheus01.deployment-prep.eqiad.wmflabs AAAA )
[...]
;; ra = 1 z = 0 ad = 0 cd = 0 rcode = NOERROR
[...]
;; deployment-prometheus01.deployment-prep.eqiad.wmflabs. IN AAAA
;; ANSWER SECTION (0 records)
[...]
;; search( deployment-prometheus01.deployment-prep.eqiad.wmflabs.deployment-prep.eqiad.wmflabs AAAA )
[...]
;; ra = 1 z = 0 ad = 0 cd = 0 rcode = NXDOMAIN
[...]
;; deployment-prometheus01.deployment-prep.eqiad.wmflabs.deployment-prep.eqiad.wmflabs. IN AAAA
[...]
;; search( deployment-prometheus01.deployment-prep.eqiad.wmflabs.eqiad.wmflabs AAAA )
[...]
;; ra = 1 z = 0 ad = 0 cd = 0 rcode = NXDOMAIN
[...]
;; deployment-prometheus01.deployment-prep.eqiad.wmflabs.eqiad.wmflabs. IN AAAA
[...]
NXDOMAIN
krenair@deployment-deploy01:~$ perl -e "require Net::DNS; my \$resolver = new Net::DNS::Resolver(); \$query = \$resolver->search('deployment-prometheus01.deployment-prep.eqiad.wmflabs.', 'A'); print \$query"
Net::DNS::Packet=HASH(0x562dad5f1318)
krenair@deployment-deploy01:~$ perl -e "require Net::DNS; my \$resolver = new Net::DNS::Resolver(); \$query = \$resolver->search('deployment-prometheus01.deployment-prep.eqiad.wmflabs.', 'AAAA'); print \$resolver->errorstring . \"\n\" . (\$query eq undef)"
NOERROR
1
krenair@deployment-deploy01:~$ perl -e "require Net::DNS; my \$resolver = new Net::DNS::Resolver(debug => 1); \$query = \$resolver->search('deployment-prometheus01.deployment-prep.eqiad.wmflabs.', 'AAAA'); print \$resolver->errorstring . \"\n\" . (\$query eq undef)"
;; search( deployment-prometheus01.deployment-prep.eqiad.wmflabs. AAAA )
[...]
;; ra = 1 z = 0 ad = 0 cd = 0 rcode = NOERROR
[...]
;; ANSWER SECTION (0 records)
[...]
NOERROR
1