removing an NM connection removes also the set renderer

Bug #2027584 reported by Alfonso Sanchez-Beato
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
netplan
Fix Committed
High
Unassigned

Bug Description

While testing netplan 0.106 from https://launchpad.net/~slyon/+archive/ubuntu/lp2023238-wpa3/ on Ubuntu Core 22:

ubuntu@ubuntu:~$ sudo snap install network-manager
network-manager (22/stable) 1.36.6-5 from Canonical✓ installed
ubuntu@ubuntu:~$ ls /etc/netplan/
00-default-nm-renderer.yaml 70-netplan-set.yaml
ubuntu@ubuntu:~$ sudo cat /etc/netplan/*
network:
  renderer: NetworkManager
network:
  version: 2

ubuntu@ubuntu:~$ nmcli c add type gsm ifname '*' con-name arkessa apn arkessa.com
Connection 'arkessa' (2e763389-e2ca-4465-b633-65b8752fed54) successfully added.

ubuntu@ubuntu:~$ nmcli c del arkessa
Connection 'arkessa' (2e763389-e2ca-4465-b633-65b8752fed54) successfully deleted.
ubuntu@ubuntu:~$ ls /etc/netplan/
70-netplan-set.yaml
ubuntu@ubuntu:~$ sudo cat /etc/netplan/*
network:
  version: 2

00-default-nm-renderer.yaml, which contains the renderer setting, has been removed. I have attached the base snap used for testing.

Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :
Revision history for this message
Lukas Märdian (slyon) wrote (last edit ):

I can reproduce this on Mantic, even using "netplan set network.modems.NM-2e763389-e2ca-4465-b633-65b8752fed54=NULL" directly, instead of "nmcli c del arkessa"

I wonder if this could be related to this refactoring:
https://github.com/canonical/netplan/commit/5985daf34e37ca8ea39358e748beeda4e09bbaef

Edit: Well, it seems to be reproducible on Kinetic (netplan.io 0.105), too. So probably unrelated..

Changed in netplan:
status: New → Triaged
importance: Undecided → High
tags: added: foundations-todo
tags: added: fr-4791
tags: added: netplan-everywhere
Revision history for this message
Lukas Märdian (slyon) wrote (last edit ):

So I found a minimal reproducer and prepared a unit-test case:

```
#!/bin/bash
# setup
netplan set network.renderer=NetworkManager --origin-hint=00-no-netdefs-just-globals
netplan set network.ethernets.eth99.dhcp4=true --origin-hint=90-some-netdefs
ls -l /etc/netplan/
# test
netplan set network.ethernets.eth99=NULL
# result
cat /etc/netplan/00-no-netdefs-just-globals.yaml
```

```
    def test_set_no_netdefs_just_globals(self): # LP: #2027584
        keepme1 = os.path.join(self.workdir.name, 'etc', 'netplan',
                              '00-no-netdefs-just-renderer.yaml')
        with open(keepme1, 'w') as f:
            f.write('''network: {renderer: NetworkManager}''')
        deleteme = os.path.join(self.workdir.name, 'etc', 'netplan',
                                '90-some-netdefs.yaml')
        with open(deleteme, 'w') as f:
            f.write('''network: {ethernets: {eth99: {dhcp4: true}}}''')

        self._set(['ethernets.eth99=NULL'])
        self.assertFalse(os.path.isfile(deleteme))
        self.assertTrue(os.path.isfile(keepme1))
        with open(keepme1, 'r') as f:
            yml = yaml.safe_load(f)
            self.assertEqual('NetworkManager', yml['network']['renderer'])
```

The issue seems to happen in Jammy+ so it's not necessarily a regression.

I'm fairly sure it's related to the combination of (as SRUed into Jammy via 0.105-0ubuntu2~22.04.2):
https://github.com/canonical/netplan/pull/254
https://github.com/canonical/netplan/pull/299

Especially, the "unlink" part at the bottom of netplan.c:netplan_state_update_yaml_hierarchy seems to ignore any global values (such as "renderer" or "version") and operates on netdefs only.

=> It should probably be fixed in conjunction with https://bugs.launchpad.net/netplan/+bug/2003727

Revision history for this message
Lukas Märdian (slyon) wrote :
Changed in netplan:
status: Triaged → In Progress
Lukas Märdian (slyon)
Changed in netplan:
status: In Progress → Fix Committed
Lukas Märdian (slyon)
tags: removed: foundations-todo
Revision history for this message
Lukas Märdian (slyon) wrote :

I confirmed the reproducer to be working with PR#382 in place in a UC22 image (via https://code.launchpad.net/~slyon/+archive/ubuntu/netplan-daily)

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.