netplan: adding routes via CLI can silently fail
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Netplan |
New
|
Medium
|
Unassigned |
Bug Description
If you already have one route defined on your interface, adding a second one via `netplan set` will silently fail:
❯ netplan get
network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses:
- "192.168.46.7/24"
routes:
- to: "default"
via: "192.168.46.1"
❯ netplan set ethernets.
❯ echo $?
0
❯ netplan get
network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses:
- "192.168.46.7/24"
routes:
- to: "default"
via: "192.168.46.1"
The issue is caused by the parsing code using invalid heuristics when avoid to add duplicate entries caused by multiple parsing of the same input file: currently, it assumes that if the input array has the same number of entries as the current routes array, it must be the same file. That is obviously not true, and will not only discard valid new input, but will only prevent duplicate entries in the simple cases.
I think this should be fixed in 0.106 via https:/ /github. com/canonical/ netplan/ pull/320