Missing dns-nameservers in eth0 with config drive on openstack instance

Bug #1712440 reported by Sabari Murugesan
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cloud-init
Expired
Undecided
Unassigned

Bug Description

Cloud Provider: OpenStack (Mitaka)
Distro: Ubuntu 16.04
Cloud-init version: 0.7.9 (cloud-init cfg is distro provider)

Other Info:
Nova Instance booted with Config Drive on a Neutron Network (without DHCP)

Problem:
when a nova instance is booted with config drive on a network with DHCP disabled, the global DNS servers passed in the network_data.json are not rendered to the eth0 interface in the /etc/network/interface.d/50-cloud-init.cfg file. It is only available on the 'lo' interface. As a result, /etc/resolv.conf is empty and all name resolutions fail.

/etc/network/interface.d/50-cloud-init.cfg looks like this
auto lo
iface lo inet loopback
    dns-nameservers 8.8.8.8

auto eth0
iface eth0 inet static
    address 192.168.111.183
    netmask 255.255.255.0
    post-up route add default gw 192.168.111.1 || true
    pre-down route del default gw 192.168.111.1 || true

instead, IMO, it should probably look like this:-

auto lo
iface lo inet loopback
    dns-nameservers 8.8.8.8

auto eth0
iface eth0 inet static
    address 192.168.111.183
    dns-nameservers 8.8.8.8 // Notice this additional dns info in eth0
    netmask 255.255.255.0
    post-up route add default gw 192.168.111.1 || true
    pre-down route del default gw 192.168.111.1 || true

I tried the fix in bug 1693265 i.e https://review.openstack.org/#/c/467699/ but it
still didn't add the dns-nameservers in the eth0 of the ENI file.

Then, I tried a custom fix (attached nova.diff) to pass the dns_namesevers
in the "networks" value of the network_data.json and that seems to fix the problem for me.

At this point, I am not clear if this is a bug in Nova or Cloud-Init to render the dns servers in ENI file correctly. Please let me know if you need more info.

Revision history for this message
Sabari Murugesan (smurugesan) wrote :
description: updated
description: updated
Revision history for this message
Sabari Murugesan (smurugesan) wrote :
Revision history for this message
Sabari Murugesan (smurugesan) wrote :
Revision history for this message
Dan Peschman (dpeschman) wrote :

Affects me, too, on OpenStack Pike & cloud-init 17.2-35-gf576b2a2-0ubuntu1~16.04.2.

Revision history for this message
Ryan Harper (raharper) wrote :

Hi,

Thanks for filing the bug.

Can you confirm that /etc/resolv.conf does *not* contain your DNS server entry? In Ubuntu cloud-images, which include the 'resolvconf' package, do get the dns entries off of *all* interfaces included in /etc/network/interfaces.d/* and combine them in /etc/resolv.conf via resolvconf package.

root@x1:~# cat /etc/cloud/build.info
build_name: server
serial: 20190621
root@x1:~# cat /etc/issue
Ubuntu 16.04.6 LTS \n \l

root@x1:~# cat /etc/network/interfaces.d/50-cloud-init.cfg
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
auto lo
iface lo inet loopback
    dns-nameservers 8.8.8.8

auto eth0
iface eth0 inet static
    address 192.168.111.183
    netmask 255.255.255.0
    post-up route add default gw 192.168.111.1 || true
    pre-down route del default gw 192.168.111.1 || true
root@x1:~# cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8

Changed in cloud-init:
status: New → Incomplete
Revision history for this message
Dan Peschman (dpeschman) wrote :

Hello. Yes I can confirm that, when this was written, the nameservers on lo would not be present in /etc/resolv.conf.

Revision history for this message
Ryan Harper (raharper) wrote :

Is this still reproducible on current Ubuntu cloud-images? I can't reproduce this behavior you're describing.

# cat /etc/network/interfaces.d/50-cloud-init.cfg
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
auto lo
iface lo inet loopback
    dns-nameservers 8.8.8.8

auto eth0
iface eth0 inet static
    address 192.168.111.183
    netmask 255.255.255.0
    post-up route add default gw 192.168.111.1 || true
    pre-down route del default gw 192.168.111.1 || true

Whenever networking service starts up, ifup on the lo interface will trigger resolvconf via this ifup hook that the resolvconf package installs:

# cat /etc/network/if-up.d/000resolvconf

That builds up a list of nameservers and search paths from the IF_DNS_NAMESERVER and DNS_SEARCH values found under the interface in the eni file, and then pipes the values to resolvconf -a lo.inet which then updates /run/resolvconf/resolv.conf to which /etc/resolv.conf is a symlink that points to the file.

root@x1:~# ls -al /etc/resolv.conf
lrwxrwxrwx 1 root root 29 Aug 7 09:15 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
root@x1:~# ifup --force lo
+ [ -x /sbin/resolvconf ]
+ :
+ R=
+ [ ]
+ [ ]
+ [ ]
+ STANDARD_IFS=

+ IFS=

+ IFS=

+ + echo/sbin/resolvconf -n -a
 lo.inet
+ [ -x /sbin/resolvconf ]
+ :
+ R=
+ [ ]
+ [ ]
+ [ ]
+ R=nameserver 8.8.8.8

+ STANDARD_IFS=

+ IFS=

+ IFS=

+ echo -n nameserver 8.8.8.8

+ /sbin/resolvconf -a lo.inet

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for cloud-init because there has been no activity for 60 days.]

Changed in cloud-init:
status: Incomplete → Expired
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.