From a5433c823d5da4b38408434d1a840ea6452fe671 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 18 May 2022 18:05:26 -0700 Subject: [PATCH] Quick fix for `get_host_dns` when resolv.conf points to resolved The Fedora infra workers got changed so their resolv.conf doesn't have the correct DNS server addresses in it any more, it just has 127.0.0.53 (the systemd-resolved resolver address). We need to query resolved to get the correct addresses. This is quick and hacky; it doesn't accommodate anyone running a worker host that *isn't* using resolved, and it doesn't handle IPv6 server addresses correctly if any are present (in infra we currently don't use any on the worker hosts). I'll try and find time to refine it but need to deploy this for now to make the tests pass again. Signed-off-by: Adam Williamson --- lib/tapnet.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/tapnet.pm b/lib/tapnet.pm index 379fe462..3b876fab 100644 --- a/lib/tapnet.pm +++ b/lib/tapnet.pm @@ -56,14 +56,13 @@ sub setup_tap_static { } sub get_host_dns { - # get DNS server addresses from the host + # get DNS server addresses from the host. Assumes host uses + # systemd-resolved and doesn't use IPv6, for now my @forwards; - open(FH, '<', "/etc/resolv.conf"); - while () { - if ($_ =~ m/^nameserver +(.+)/) { - push @forwards, $1; - } - } + my $result = `/usr/bin/resolvectl status | grep Servers | tail -1 | cut -d: -f2-`; + # FIXME this is gonna break when we have IPv6 DNS servers on the + # worker hosts + my @forwards = split(' ', $result); return @forwards; }