1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-21 13:33:08 +00:00

Get dns server address if host isn’t using systemd-resolved

The worker containers aren’t using systemd-resolved so
get_host_dns() can’t find the dns server causing tests that need
it to fail. Add an alternative place to look for the dns server address
that doesn’t rely on systemd-resolved.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
This commit is contained in:
Deborah Brouwer 2024-03-07 13:11:03 -08:00 committed by adamwill
parent c3baa66465
commit 4eec75bec3

View File

@ -62,6 +62,17 @@ sub get_host_dns {
# FIXME this is gonna break when we have IPv6 DNS servers on the
# worker hosts
my @forwards = split(' ', $result);
# Alternatively, for hosts that aren't running systemd, read /etc/resolv.conf
if (!@forwards && open(my $fh, '<', "/etc/resolv.conf")) {
while (<$fh>) {
next if /:/; # ignore ipv6 addresses
if ($_ =~ m/^nameserver +(.+)/) {
push @forwards, $1;
}
}
close($fh);
}
return @forwards;
}