** Description changed:
- While working on the snapd netplan integration I ran into the following
peculiar issue.
- I want to unset a subtree of configuration, e.g. I have:
- # netplan get
+ [Impact]
+
+ The netplan CLI would crash when trying to set an entire device type
+ subtree to null, e.g. `netplan set devices.ethernets=null`, and the
+ configuration would remain unaffected. This is obviously undesirable, as
+ the only workaround is to explictly loop through all the definitions.
+
+ The fix comes in two parts:
+
+ * add some internal APIs to libnetplan to be able to list all defintions
+ of a given type, with some care taken in the consuming Python bindings
+ if the symbols aren't present.
+
+ * use this new API to, when encountering this special case, expand the
+ devtype subtree into all its definitions, letting the normal subtree
+ nullification feature taking it up from there.
+
+ [Test Plan]
+
+ Boot a VM image with at least one ethernet device.
+ Write the following config to /etc/netplan/00-ethernets.yaml
+
network:
version: 2
ethernets:
all-en:
dhcp4: true
match:
name: en*
all-eth:
dhcp4: true
match:
name: eth*
+ Check that it has been taken into account using this command
+
+ netplan get
+
+ Unset the definitions we added:
+
+ netplan set network.ethernets=null
+
+ This command should silently succeed.
+ Finally, check that there are no ethernet device configured by running
+
+ netplan get
+
+ [Where problems could occur]
+
+ This is backported from a branch with considerable changes in the API
+ and ABI handling of libnetplan, so some ABI breakage might slip through
+ unnoticed, even though steps have been taken to prevent it.
+
+ The most risk of regression is in the `netplan set` command, as it is
+ where the existing code actually changes behaviour. This could be
+ particularly bad as this could overwrite existing configuration files
+ with erroneous configuration, leading to non-functional networking.
+
+ Also, the DBus endpoints for netplan directly uses the `netplan set`
+ command, so its users could be impacted as well.
+
+ [Original report]
+
+ While working on the snapd netplan integration I ran into the following
peculiar issue.
+ I want to unset a subtree of configuration, e.g. I have:
+ # netplan get
+ network:
+ version: 2
+ ethernets:
+ all-en:
+ dhcp4: true
+ match:
+ name: en*
+ all-eth:
+ dhcp4: true
+ match:
+ name: eth*
+
and want to remove all ethernet configuration. AIUI this can be done via
setting the subtree to "null" (or did I misunderstood this)? If I try
that I get:
# netplan set network.ethernets=null
Traceback (most recent call last):
- File "/usr/sbin/netplan", line 23, in <module>
- netplan.main()
- File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
- self.run_command()
- File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
- self.func()
- File "/usr/share/netplan/netplan/cli/commands/set.py", line 52, in run
- self.run_command()
- File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
- self.func()
- File "/usr/share/netplan/netplan/cli/commands/set.py", line 95, in
command_set
- hints = self.split_tree_by_hint(set_tree)
- File "/usr/share/netplan/netplan/cli/commands/set.py", line 61, in
split_tree_by_hint
- for netdef in network.get(devtype, []):
+ File "/usr/sbin/netplan", line 23, in <module>
+ netplan.main()
+ File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
+ self.run_command()
+ File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
+ self.func()
+ File "/usr/share/netplan/netplan/cli/commands/set.py", line 52, in run
+ self.run_command()
+ File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
+ self.func()
+ File "/usr/share/netplan/netplan/cli/commands/set.py", line 95, in
command_set
+ hints = self.split_tree_by_hint(set_tree)
+ File "/usr/share/netplan/netplan/cli/commands/set.py", line 61, in
split_tree_by_hint
+ for netdef in network.get(devtype, []):
TypeError: 'NoneType' object is not iterable
Do you have any hints how I can delete an entire subtree via the
commandline (well, via dbus but it's a direct mapping so cmdline is
fine).
This is Ubuntu Core 20 with netplan 0.102-0ubuntu1~20.04.2 but I can also
reproduce this on my 21.04 system with:
$ sudo netplan get
network:
- bridges:
- br54:
- dhcp4: true
- dhcp6: true
- renderer: NetworkManager
- version: 2
+ bridges:
+ br54:
+ dhcp4: true
+ dhcp6: true
+ renderer: NetworkManager
+ version: 2
$ sudo netplan set network.bridges=null
Traceback (most recent call last):
- File "/usr/sbin/netplan", line 23, in <module>
- netplan.main()
- File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
- self.run_command()
- File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
- self.func()
- File "/usr/share/netplan/netplan/cli/commands/set.py", line 52, in run
- self.run_command()
- File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
- self.func()
- File "/usr/share/netplan/netplan/cli/commands/set.py", line 95, in
command_set
- hints = self.split_tree_by_hint(set_tree)
- File "/usr/share/netplan/netplan/cli/commands/set.py", line 61, in
split_tree_by_hint
- for netdef in network.get(devtype, []):
+ File "/usr/sbin/netplan", line 23, in <module>
+ netplan.main()
+ File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
+ self.run_command()
+ File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
+ self.func()
+ File "/usr/share/netplan/netplan/cli/commands/set.py", line 52, in run
+ self.run_command()
+ File "/usr/share/netplan/netplan/cli/utils.py", line 264, in run_command
+ self.func()
+ File "/usr/share/netplan/netplan/cli/commands/set.py", line 95, in
command_set
+ hints = self.split_tree_by_hint(set_tree)
+ File "/usr/share/netplan/netplan/cli/commands/set.py", line 61, in
split_tree_by_hint
+ for netdef in network.get(devtype, []):
TypeError: 'NoneType' object is not iterable
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1942930
Title:
Unset a subtree crashes
To manage notifications about this bug go to:
https://bugs.launchpad.net/netplan/+bug/1942930/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs