Unset of a subtree crashes with invalid (non existing) origin-hint
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
netplan |
Fix Released
|
Low
|
Lukas Märdian | ||
netplan.io (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Focal |
Fix Released
|
Undecided
|
Unassigned | ||
Hirsute |
Fix Released
|
Undecided
|
Unassigned | ||
Impish |
Fix Released
|
Undecided
|
Unassigned | ||
Jammy |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
[Impact]
snapd uses netplan's DBus API to create config objects and set/try/apply changed configuration. It uses origin-hints (like 90-snapd-conf.yaml) to separate it's configuration from the user owned YAML configuration.
If this origin-hint file does not exist or is empty, it might lead to crashes inside the 'netplan set' CLI, depending on the called operation and configuration.
[Test Plan]
In addition to running & passing the full set of unit- and integration-tests (that contains new tests to check for the cases described in this bug), as described in https:/
$ ./netplan-
$ ./repro.sh
autopkgtest logs:
* Impish:
https:/
https:/
https:/
https:/
https:/
* Hirsute:
https:/
https:/
https:/
https:/
https:/
* Focal:
https:/
https:/
https:/
https:/
https:/
[Where problems could occur]
This upload contains changes to the CLI of netplan, if anything goes wrong it could impact the interactive usage of 'netplan set' by the user.
[Other Info]
The full set of autopkgtest logs will be attached after the upload is accepted into -proposed and the tests have been run on the official autopkgtest.u.c
infrastructure.
=== Original Description ===
Hey, sorry to bother you again with a crash. Help welcome!
I have:
$ $ apt list netplan.io
Listing... Done
netplan.io/now 0.103-0ubuntu5~
$ zcat /usr/share/
netplan.io (0.103-
* Backport patches from impish:
+ Add d/p/0006-
Fix unset of a devtype subtree, e.g. "netplan set network.
(LP: #1942930)
With:
$ netplan get
network:
renderer: NetworkManager
version: 2
When I do the following:
$ sudo netplan set network.
that works just fine now.
But when I do (what I think is) the dbus equivalent:
path=$(dbus-send --system --print-reply --type=method_call --dest=
dbus-send --system --print-reply --type=method_call --dest=
I get:
Error org.freedesktop
stdout: ''
stderr: 'Traceback (most recent call last):
File "/usr/sbin/
netplan.main()
File "/usr/share/
self.
File "/usr/share/
self.func()
File "/usr/share/
self.
File "/usr/share/
self.func()
File "/usr/share/
self.
File "/usr/share/
raise Exception('Invalid input: {}'.format(
Exception: Invalid input: {'network': {'ethernets': None}}
'
Any help or tips appreciated!
summary: |
- Unset of a subtree crashes with dbus (but not cli) + Unset of a subtree crashes with invalid (non existing) origin-hint |
description: | updated |
Changed in netplan: | |
status: | In Progress → Fix Committed |
Changed in netplan: | |
status: | Fix Committed → Fix Released |
Okay, I think this is actually a combination of invalid usage and non-optimal error handling. I can reproduce the error locally on Impish:
# busctl call io.netplan.Netplan /io/netplan/Netplan io.netplan.Netplan Config Netplan/ config/ DS7XA1" Netplan/ config/ DS7XA1 io.netplan. Netplan. Config Set ss "network. ethernets= null" "90-snapd-conf" netplan" , line 23, in <module> netplan/ netplan/ cli/core. py", line 50, in main run_command( ) netplan/ netplan/ cli/utils. py", line 310, in run_command netplan/ netplan/ cli/commands/ set.py" , line 53, in run run_command( ) netplan/ netplan/ cli/utils. py", line 310, in run_command netplan/ netplan/ cli/commands/ set.py" , line 106, in command_set write_file( subtree, hint + '.yaml', self.root_dir) netplan/ netplan/ cli/commands/ set.py" , line 176, in write_file set_tree) )
o "/io/netplan/
# busctl call io.netplan.Netplan /io/netplan/
Call failed: netplan set failed: Child process exited with code 1
stdout: ''
stderr: 'Traceback (most recent call last):
File "/usr/sbin/
netplan.main()
File "/usr/share/
self.
File "/usr/share/
self.func()
File "/usr/share/
self.
File "/usr/share/
self.func()
File "/usr/share/
self.
File "/usr/share/
raise Exception('Invalid input: {}'.format(
Exception: Invalid input: {'network': {'ethernets': None}}
BUT: That only seems to happen if the file hint (here: 90-snapd-conf.yaml) does not exist. If 90-snapd-conf.yaml is filled with some config before, it works as expected:
# busctl call io.netplan.Netplan /io/netplan/ Netplan/ config/ DS7XA1 io.netplan. Netplan. Config Set ss "network. ethernets. eth99.dhcp4= true" "90-snapd-conf" Netplan/ config/ DS7XA1 io.netplan. Netplan. Config Set ss "network. ethernets= null" "90-snapd-conf"
b true
# busctl call io.netplan.Netplan /io/netplan/
b true
Also, if you want to clear any ethernet definition (not just the ones from 90-snapd-conf.yaml) you could pass an empty origin hint, to make it work:
# busctl call io.netplan.Netplan /io/netplan/ Netplan/ config/ DS7XA1 io.netplan. Netplan. Config Set ss "network. ethernets= null" ""
b true
BTW: the same issue happens with the CLI, if you pass a non existing origin-hint and we should probably improve the error handling and error message in cli/commands/set.py -> write_file():
# netplan set network. ethernets= null --origin-hint NON_EXISTING_FILE netplan" , line 23, in <module> netplan/ netplan/ cli/core. py", line 50, in main run_command( ) netplan/ netplan/ cli/utils. py", line 310, in run_command netplan/ netplan/ cli/commands/ set.py" , line 53, in run run_command( ) netplan/ netplan/ cli/utils. py", line 310, in run_command netplan/ netplan/ cli/commands/ set.py" , line 106, in command_set write_file( subtree, hint + '.yaml', self.root_dir) netplan/ netplan/ cli/commands/ set.py" , line 176, in write_file set_tree) )
Traceback (most recent call last):
File "/usr/sbin/
netplan.main()
File "/usr/share/
self.
File "/usr/share/
self.func()
File "/usr/share/
self.
File "/usr/share/
self.func()
File "/usr/share/
self.
File "/usr/share/
raise Exception('Invalid input: {}'.format(
Exception: Invalid input: {'network': {'ethernets': None}}