debcrafters-packages team mailing list archive
-
debcrafters-packages team
-
Mailing list archive
-
Message #00218
[Bug 2104373] Re: [Bug] Failed 'netplan set' operation doesn't return non-0 error (Netplan 1.1.1 in Ubuntu 24.04)
@slyon please check https://github.com/canonical/netplan/pull/551
I left some comments. Since I'm new Netplan contributor, I encountered
multiple issues. If you think this is overall better to be implemented
by someone from core team (because of complications with tests), please
let me know. It's OK from my side.
--
You received this bug notification because you are a member of
Debcrafters packages, which is subscribed to netplan.io in Ubuntu.
https://bugs.launchpad.net/bugs/2104373
Title:
[Bug] Failed 'netplan set' operation doesn't return non-0 error
(Netplan 1.1.1 in Ubuntu 24.04)
Status in Netplan:
New
Status in netplan.io package in Ubuntu:
Triaged
Status in netplan.io source package in Jammy:
New
Status in netplan.io source package in Noble:
New
Status in netplan.io source package in Oracular:
New
Status in netplan.io source package in Plucky:
Triaged
Bug description:
Hello,
Me and my colleagues encountered a bug in Netplan that was introduced
in Ubuntu 24.04.
When `netplan set` is executed, for example to add bridge that
references non-existing interface, the error code (return value of the
cmd $?) is `0` in Ubuntu 24.04. In Ubuntu 22.04 the error code is
proper `1` (non-zero).
Here are generic steps that can be done with any Ubuntu 22.04 and
24.04 VM to reproduce the issue:
Get an Ubuntu 22.04 VM - this is example of proper behavior:
```bash
root@ubuntu-22-machine:~# netplan set --debug --origin-hint 10-test.network network.bridges.br1='{"interfaces":["nonexisting-interface"]}'
Traceback (most recent call last):
File "/usr/sbin/netplan", line 23, in <module>
netplan.main()
File "/usr/share/netplan/netplan/cli/core.py", line 56, in main
self.run_command()
File "/usr/share/netplan/netplan/cli/utils.py", line 243, in run_command
self.func()
File "/usr/share/netplan/netplan/cli/commands/set.py", line 50, in run
self.run_command()
File "/usr/share/netplan/netplan/cli/utils.py", line 243, in run_command
self.func()
File "/usr/share/netplan/netplan/cli/commands/set.py", line 85, in command_set
parser.load_yaml(tmp)
File "/usr/share/netplan/netplan/libnetplan.py", line 119, in load_yaml
_checked_lib_call(lib.netplan_parser_load_yaml_from_fd, self._ptr, input_file.fileno())
File "/usr/share/netplan/netplan/libnetplan.py", line 79, in _checked_lib_call
raise LibNetplanException(err.contents.message.decode('utf-8'))
netplan.libnetplan.LibNetplanException: Error in network definition: br1: interface 'nonexisting-interface' is not defined
root@ubuntu-22-machine:~# echo $?
1
root@ubuntu-22-machine:~# dpkg -l | grep netplan
hi libnetplan0:amd64 0.106.1-7ubuntu0.22.04.4 amd64 YAML network configuration abstraction runtime library
hi netplan.io 0.106.1-7ubuntu0.22.04.4 amd64 YAML network configuration abstraction for various backends
root@ubuntu-22-machine:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: jammy
```
Get an Ubuntu 24.04 VM - this is wrong behavior introduced in this
Ubuntu version. The return value of `netplan set` must be different
than `0` because there is an error and command failed:
```bash
root@ubuntu-24-machine:~# netplan set --debug --origin-hint 10-test.network network.bridges.br1='{"interfaces":["nonexisting-interface"]}'
Command failed: Error in network definition: br1: interface 'nonexisting-interface' is not defined
eroot@ubuntu-24-machine:~# echo $?
0
root@ubuntu-24-machine:~# dpkg -l | grep netplan
hi libnetplan1:amd64 1.1.1-1~ubuntu24.04.1 amd64 Declarative network configuration runtime library
hi netplan-generator 1.1.1-1~ubuntu24.04.1 amd64 Declarative network configuration for various backends at boot
hi netplan.io 1.1.1-1~ubuntu24.04.1 amd64 Declarative network configuration for various backends at runtime
hi python3-netplan 1.1.1-1~ubuntu24.04.1 amd64 Declarative network configuration Python bindings
root@ubuntu-24-machine:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: noble
```
Based on a troubleshooting session with my colleagues we think we may found out what the issue is (please verify - we are not experts on netplan codebase):
- The bug was introduced probably in commit https://github.com/canonical/netplan/commit/d06c73d09f6081419bd423526b3d4516f14f523a where in file `src/error.c` branching in `yaml_error` function has changed.
- In the `else` branch the return code is `NETPLAN_ERROR_CONFIG_GENERIC` which is `0` (see this diff https://github.com/canonical/netplan/commit/d06c73d09f6081419bd423526b3d4516f14f523a#diff-0785f4cf8a2cc06d90d511879d9b43ff9f69858fceb83bc13a5f78bd8b3a9187R162-R177).
Impact scope:
- This wrong behavior breaks manual CLI commands, scripts and tooling that depends on netplan CLI.
- Additionally the error code is also not reflected to netplan-dbus. When you execute the same command as above to add bridge using netplan-dbus - it will not report error even though netplan command fails.
To manage notifications about this bug go to:
https://bugs.launchpad.net/netplan/+bug/2104373/+subscriptions