Comment 12 for bug 1869181

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

Thanks for the additional details.

From the logs and some local testing, the best choice for
getting things to work with the desktop image via MAAS is

to remove the 01-network-manager-all.yaml file before rebooting into the
target. This will allow networking to be fully managed by networkd.

We will likely need to file some bugs to get NetworkManager and cloud-init
and netplan to work together.

1) NetworkManager.service and NetworkManager-wait-online.service run too late
to work with cloud-init, This can be fixed by

   a) Adding DefaultDependencies=no to both NM service files
   b) cloud-init.service also adds a After=NetworkManager-wait-online.service

   Note, both of these changes can be done via systemd-drop in files but
   ideally they would go into the package itself.

2) The rendered NM configuration is not complete enough to auto enable
the configuration.

cloud-init writes a netplan config file and calls netplan generate which
with NetworkManager renderer populates /run/NetworkManager with config

# find /run/NetworkManager/ -type f
/run/NetworkManager/resolv.conf
/run/NetworkManager/no-stub-resolv.conf
/run/NetworkManager/devices/30
/run/NetworkManager/conf.d/10-globally-managed-devices.conf
/run/NetworkManager/system-connections/netplan-eth0.nmconnection

NetworkManager.service comes up and it can "see" an 'eth0' connection
and a 'netplan-eth0' connection. The 'eth0' connection is enabled.

# nmcli conn
NAME UUID TYPE DEVICE
eth0 e8ffebad-dba7-4035-a9a8-29d9e004e6c1 ethernet eth0
netplan-eth0 626dd384-8b3d-3690-9511-192b2c79b3fd ethernet --

eth0 has no IP (it's configured for dhcp)

After running netplan apply, we can see this change
# netplan --debug apply
** (generate:476): DEBUG: 15:39:02.332: Processing input file /etc/netplan/01-network-manager-all.yaml..
** (generate:476): DEBUG: 15:39:02.332: starting new processing pass
** (generate:476): DEBUG: 15:39:02.332: Processing input file /etc/netplan/50-cloud-init.yaml..
** (generate:476): DEBUG: 15:39:02.332: starting new processing pass
** (generate:476): DEBUG: 15:39:02.332: eth0: setting default backend to 2
** (generate:476): DEBUG: 15:39:02.332: Configuration is valid
** (generate:476): DEBUG: 15:39:02.332: Generating output files..
** (generate:476): DEBUG: 15:39:02.332: networkd: definition eth0 is not for us (backend 2)
(generate:476): GLib-DEBUG: 15:39:02.332: posix_spawn avoided (fd close requested)
DEBUG:netplan generated networkd configuration changed, restarting networkd
DEBUG:netplan generated NM configuration changed, restarting NM
DEBUG:eth0 not found in {}
DEBUG:Merged config:
network:
  bonds: {}
  bridges: {}
  ethernets:
    eth0:
      dhcp4: true
      match:
        macaddress: 00:16:3e:0d:4c:a7
      set-name: eth0
  vlans: {}
  wifis: {}

DEBUG:Skipping non-physical interface: lo
DEBUG:device eth0 operstate is up, not changing
DEBUG:{}
DEBUG:netplan triggering .link rules for lo
DEBUG:netplan triggering .link rules for eth0

# nmcli conn
NAME UUID TYPE DEVICE
netplan-eth0 626dd384-8b3d-3690-9511-192b2c79b3fd ethernet eth0

Looking into NM logs, there is a auto-enable policy that netplan apply
triggers that does not seem to happen with just restarting NM.

# journalctl -o short-precise -b -u NetworkManager.service | grep policy
Apr 14 15:39:02.871859 f6 NetworkManager[520]: <info> [1586878742.8718] policy: auto-activating connection 'netplan-eth0' (626dd384-8b3d-3690-9511-192b2c79b3fd)
Apr 14 15:39:02.887910 f6 NetworkManager[520]: <info> [1586878742.8878] policy: set 'netplan-eth0' (eth0) as default for IPv4 routing and DNS

I don't think cloud-init itself should have to run 'netplan apply'; we don't
do this for networkd backend.