#314 Get dns server address if host isn’t using systemd-resolved
Merged a month ago by adamwill. Opened 2 months ago by dbrouwer.
fedora-qa/ dbrouwer/os-autoinst-distri-fedora dns_resolution  into  main

file modified
+11
@@ -62,6 +62,17 @@ 

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

  }

  

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

why not just grep 'nameserver' /etc/resolv.conf instead of cat /etc/resolv.conf | grep 'nameserver'? aside from that, sure! should be fine.

actually, huh. according to me in https://pagure.io/fedora-qa/os-autoinst-distri-fedora/c/a5433c823d5da4b38408434d1a840ea6452fe671?branch=main , the current implementation is a quick hack. I had completely forgotten about this, probably because it kept working. I probably meant to do something a bit more sophisticated at some point.

maybe you could use the old resolv.conf-based implementation I had (the 'before' of that commit) in your conditional instead of this one...

Sure, yes, when I tested the 'before' commit, I needed to tweak it just to force it to take only one nameserver address and to ignore any ipv6 addresses that might appear.

rebased onto aec6de4

2 months ago

rebased onto 50b39f1

2 months ago

ah, I see. taking just one nameserver is not actually the intent, though - the function is meant to get all of them. the systemd version gets all the nameservers on one line and calls split() on it.

i see what you mean - sending all of the ipv4 addresses does work fine now that i am removing the ipv6 addresses

rebased onto f107444

2 months ago

rebased onto 4eec75b

a month ago

sorry, forgot about this. looks good, merging.

Pull-Request has been merged by adamwill

a month ago
Metadata