cloud-init does not provide configurable network activator priority overrides

Bug #1982857 reported by Chad Smith
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Undecided
Chad Smith
subiquity
New
Undecided
Unassigned

Bug Description

cloud-init has two interactions with network backplanes

1. to write (or render) network configuration to the approapriate config files for the network system: systemd, netplan, network-manager, ENI, freebsd, netbsd, openbsd. This is done via cloudinit.net.renderers discovery[1]

2. optionally to bring up the network configuration via "network activation" for datasources discovered only in init boot stage after network is already up[2]

/etc/cloud/cloud.cfg allows system_info:network:renderers to configure overrides for default renderers, but not for activators. The two discovery/mechanisms don't know about each other and have separate logic to determine which is applicable on the given system.

Cloud-init should either:
 - Expose system_info: network: activators discovery priorty/order configuration in /etc/cloud/cloud.cfg*

 -- OR --

 - make activators aware of customized/overridden renderers priority from cloud.cfg and honor that priority order when discovering activators to use.

Without this feature, overridden network: renderer priority order to set network-manager as default renderer will result in cloud-init writing /etc/NetworkManager/system-connections/cloud-init-<NIC_NAME>.nmconnection but then trying to run `netplan apply` for a non-existent configuration on ubuntu Desktop installs.

References:
[1] network renderers discovery: https://github.com/canonical/cloud-init/blob/main/cloudinit/net/renderers.py#L67
[2] network activators discovery: https://github.com/canonical/cloud-init/blob/main/cloudinit/net/activators.py#L279
[3] renderer overrides honored: https://github.com/canonical/cloud-init/blob/main/cloudinit/distros/__init__.py#L122-L126
[4] No activator overrides: https://github.com/canonical/cloud-init/blob/main/cloudinit/distros/__init__.py#L246

Tags: bitesize
Revision history for this message
Chad Smith (chad.smith) wrote :

Adding subiquity FYI for ubuntu-desktop-installer. This fix will be required from cloud-init if subiquity installer/ephemeral environment wants to override network: activators: [network-manager] in /etc/cloud/cloud.cfg.d/*cfg

description: updated
tags: added: bitesize
description: updated
Revision history for this message
Chad Smith (chad.smith) wrote (last edit ):

Logs on a system with renderers overridden to prefer NetworkManager but activators not aware and choosing netplan.

ubuntu@ubuntu:~$ cat /etc/cloud/cloud.cfg.d/99-installer-use-network-manager.cfg
system_info:
 network:
   renderers: [network-manager]

ubuntu@ubuntu:~$ egrep 'NetworkManager|netplan|activator|renderer' /var/log/cloud-init.log
2022-07-26 16:41:20,871 - subp.py[DEBUG]: Running command ['systemctl', 'is-enabled', 'NetworkManager.service'] with allowed return codes [0] (shell=False, capture=True)
2022-07-26 16:41:20,877 - __init__.py[DEBUG]: Selected renderer 'network-manager' from priority list: ['network-manager']
2022-07-26 16:41:20,877 - util.py[DEBUG]: Writing to /etc/NetworkManager/system-connections/cloud-init-enp0s31f6.nmconnection - wb: [600] 278 bytes
2022-07-26 16:41:34,276 - subp.py[DEBUG]: Running command ['systemctl', 'is-enabled', 'NetworkManager.service'] with allowed return codes [0] (shell=False, capture=True)
2022-07-26 16:41:34,279 - __init__.py[DEBUG]: Selected renderer 'network-manager' from priority list: ['network-manager']
2022-07-26 16:41:34,279 - util.py[DEBUG]: Writing to /etc/NetworkManager/system-connections/cloud-init-enp0s31f6.nmconnection - wb: [600] 278 bytes
2022-07-26 16:41:34,279 - subp.py[DEBUG]: Running command ['systemctl', 'is-enabled', 'NetworkManager.service'] with allowed return codes [0] (shell=False, capture=True)
2022-07-26 16:41:34,282 - activators.py[DEBUG]: Using selected activator: <class 'cloudinit.net.activators.NetplanActivator'>
2022-07-26 16:41:34,282 - activators.py[DEBUG]: Attempting command ['netplan', 'apply'] for device all
2022-07-26 16:41:34,282 - subp.py[DEBUG]: Running command ['netplan', 'apply'] with allowed return codes [0] (shell=False, capture=True)

Changed in cloud-init:
status: New → Triaged
Revision history for this message
Chad Smith (chad.smith) wrote :
Revision history for this message
Chad Smith (chad.smith) wrote :

upstream PR related to this bug in progress
https://github.com/canonical/cloud-init/pull/1619

Changed in cloud-init:
status: Triaged → In Progress
assignee: nobody → Chad Smith (chad.smith)
Revision history for this message
Chad Smith (chad.smith) wrote :
Changed in cloud-init:
status: In Progress → Fix Committed
Revision history for this message
shixuantong (sxt1001) wrote :

The problem seems to have been resolved, we can close it.

James Falcon (falcojr)
Changed in cloud-init:
status: Fix Committed → Fix Released
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.