bionic: DNS search domains lost from cloud-init to netplan

Bug #1774540 reported by Ryan Finnie
8
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cloud-init
Expired
Medium
Unassigned

Bug Description

On a deployed node with a MAAS datasource, /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg contains:

network:
  config:
  - id: enp1s0
    mac_address: 52:54:00:9a:b4:64
    mtu: 1500
    name: enp1s0
    subnets:
    - address: 10.48.7.48/21
      dns_nameservers:
      - 10.48.0.5
      gateway: 10.48.0.1
      type: static
    type: physical
  - address:
    - 10.48.0.5
    search:
    - bos01.canonistack.internal
    type: nameserver
  version: 1

But the generated /etc/netplan/50-cloud-init.yaml contains no search domains under nameservers for the interface:
# 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}
network:
    version: 2
    ethernets:
        enp1s0:
            addresses:
            - 10.48.7.48/21
            gateway4: 10.48.0.1
            match:
                macaddress: 52:54:00:9a:b4:64
            mtu: 1500
            nameservers:
                addresses:
                - 10.48.0.5
            set-name: enp1s0

Related bugs:
 * bug 1750884: /etc/resolv.conf not configured correctly in Bionic, leads to no DNS resolution

Ryan Finnie (fo0bar)
description: updated
Revision history for this message
Scott Moser (smoser) wrote :

This is related to bug 1750884.
In netplan/systemd-networkd there is no such thing as "global" dns. The decision was made that although users configured dns globally for the vast majority of the last 30 years, we were not going to support that behavior any more in netplan or systemd-networkd.

Under that bug, though, cloud-init worked around by copying the 'nameserver' settings from the global section to each interface.

Curiously, though, we did not copy the search entries.

I am not sure why.

description: updated
Changed in cloud-init:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Ryan Harper (raharper) wrote :

The searchpath is copied. In netplan , the config namespace is:

nameservers:
   - addresses: [x, y]
   - search: [a, b]

The relevant code in cloudinit/net/netplan.py:

# inject global nameserver values under each all interface which
# has addresses and do not already have a DNS configuration
if nameservers or searchdomains:
    nscfg = {'addresses': nameservers, 'search': searchdomains}
    for section in [ethernets, wifis, bonds, bridges, vlans]:
        for _name, cfg in section.items():
            if 'nameservers' in cfg or 'addresses' not in cfg:
                continue
            cfg.update({'nameservers': nscfg})

Note the nscfg contains both the nameservers and the searchdomains.

Revision history for this message
Scott Moser (smoser) wrote :

@Ryan,

I marked this confirmed because the issue reproduces with current master and 'net-convert.py'.
I think the issue here is that the subnet had dns_nameservers. but 'search' was only declared at the global level.

The patch http://paste.ubuntu.com/p/k3hjFPv5qD/ will fix this issue.

$ cat my.cfg
network:
  config:
  - id: enp1s0
    mac_address: 52:54:00:9a:b4:64
    mtu: 1500
    name: enp1s0
    subnets:
    - address: 10.48.7.48/21
      dns_nameservers:
      - 10.48.0.5
      gateway: 10.48.0.1
      type: static
    type: physical
  - address:
    - 10.48.0.5
    search:
    - bos01.canonistack.internal
    type: nameserver
  version: 1

$ PYTHONPATH=$PWD ./tools/net-convert.py --network-data=my.cfg --kind=yaml -d out.d --output-kind=netplan

$ cat out.d/etc/netplan/50-cloud-init.yaml

network:
    version: 2
    ethernets:
        enp1s0:
            addresses:
            - 10.48.7.48/21
            gateway4: 10.48.0.1
            match:
                macaddress: 52:54:00:9a:b4:64
            mtu: 1500
            nameservers:
                addresses:
                - 10.48.0.5
            set-name: enp1s0

Revision history for this message
James Falcon (falcojr) wrote :
Changed in cloud-init:
status: Confirmed → Expired
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.