multiple definitions of device ids between files are combined

Bug #1665078 reported by Ryan Harper
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Netplan
New
Undecided
Unassigned

Bug Description

There was a question as to what behavior we would see if multiple yaml files were included that reference the same device. The 05-snappy.yaml is a catch-all "DHCP on the first physical device called eth0" which generates a [Match]\nOriginalName=eth0. The second config applies a static IP and matches based on mac. The resulting eth0.* networkd files are a combination of both configurations.

I believe this is expected behavior but it does mean that if something like cloud-init generates networking configuration from user-data then it cannot keep existing netplan configurations around.

I'll leave this bug here which may be rejected as Invalid if this is expected behavior; It's likely not a bug since documentation indicates that the device identifiers must be unique

https://git.launchpad.net/netplan/tree/doc/netplan.md#n51

However, if this is the case, it would be reasonable to emit an error when they're not if the property in the documentation holds.

root@ubuntu:/etc/netplan# apt-cache policy nplan
nplan:
  Installed: 0.18
  Candidate: 0.18
  Version table:
 *** 0.18 500
        500 http://archive.ubuntu.com/ubuntu zesty/main amd64 Packages
        100 /var/lib/dpkg/status
root@ubuntu:/etc/netplan# lsb_release -rd
Description: Ubuntu Zesty Zapus (development branch)
Release: 17.04

root@ubuntu:/run/systemd/network# ls -al /etc/netplan/*.yaml
-rw-r--r-- 1 root root 63 Feb 15 18:48 /etc/netplan/05-snappy.yaml
-rw-r--r-- 1 root root 822 Feb 15 18:50 /etc/netplan/52-bridge.yaml

root@ubuntu:/etc/netplan# cat *.yaml
network:
  version: 2
  ethernets:
    eth0:
      dhcp4: true
network:
    ethernets:
        eth0:
            addresses:
            - 10.11.12.13/24
            match:
                macaddress: '52:54:00:12:34:00'
            set-name: foobar0
        eth1:
            match:
                macaddress: '52:54:00:12:34:02'
            set-name: eth1
        eth2:
            match:
                macaddress: '52:54:00:12:34:04'
            set-name: eth2
    bridges:
        br0:
            addresses:
            - 192.168.14.2/24
            interfaces:
            - eth1
            - eth2
            parameters:
                ageing-time: 250
                priority: 22
                forward-delay: 1
                hello-time: 1
                max-age: 10
                path-cost:
                    eth1: 50
                    eth2: 75
    version: 2

root@ubuntu:/etc/netplan# netplan generate
root@ubuntu:/etc/netplan# cd /run/systemd/network/
root@ubuntu:/run/systemd/network# ls -al
total 32
drwxr-xr-x 2 root root 200 Feb 15 18:51 .
drwxr-xr-x 19 root root 460 Feb 15 15:39 ..
-rw-r--r-- 1 root root 116 Feb 15 18:51 10-netplan-br0.netdev
-rw-r--r-- 1 root root 52 Feb 15 18:51 10-netplan-br0.network
-rw-r--r-- 1 root root 90 Feb 15 18:51 10-netplan-eth0.link
-rw-r--r-- 1 root root 118 Feb 15 18:51 10-netplan-eth0.network
-rw-r--r-- 1 root root 69 Feb 15 18:51 10-netplan-eth1.link
-rw-r--r-- 1 root root 126 Feb 15 18:51 10-netplan-eth1.network
-rw-r--r-- 1 root root 69 Feb 15 18:51 10-netplan-eth2.link
-rw-r--r-- 1 root root 126 Feb 15 18:51 10-netplan-eth2.network
root@ubuntu:/run/systemd/network# cat *eth0*
[Match]
MACAddress=52:54:00:12:34:00
OriginalName=eth0

[Link]
Name=foobar0
WakeOnLan=off
[Match]
MACAddress=52:54:00:12:34:00
Name=foobar0

[Network]
DHCP=ipv4
Address=10.11.12.13/24

[DHCP]
RouteMetric=100

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

This is expected behavior:

       /* Files with asciibetically higher names override/append settings from
         * earlier ones (in all config dirs); files in /run/netplan/
         * shadow files in /etc/netplan/ which shadow files in /lib/netplan/.

You are meant to be able to generate cross-referencing configuration files or global configs which can then be invalidated by later files referencing the same devices and overriding the settings -- this allows shipping "global" configuration files with defaults, which are then customized to a user's liking via later files, possibly in a different directory.

My understanding is that it however means that you will not be able to reuse the name "eth0" as the name of a bond or another type of device if it has already been defined as an ethernet.

Changed in netplan:
status: New → Invalid
Revision history for this message
Ryan Harper (raharper) wrote :

Ensuring that netplan parses the while file is not the same as the order in which netplan parses individual configuration files.

If I ship the attached file as the *only* netplan configuration file on the whole system surely I can expect netplan to *parse* the whole file, and then generate a configuration.

I suspect things like bridged vlan bonds is going to have a certain amount of cross referencing that's going to be problematic for single-pass rendering.

Changed in netplan:
status: Invalid → New
Revision history for this message
Ryan Harper (raharper) wrote :

Ignore my comment above, I was confused.

For this bug

1. We should document the id namespace issue
2. Netplan should detect and generate a warning/error message so folks don't continue to ship (and are at least pointed to the file further up in the hierarchy that is claiming/defining the id.

tags: added: no-maas-impact
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.