new netplan set has issues in adding or overwriting addresses and routes

Bug #2009006 reported by Leonardo Saccardi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
netplan
Triaged
Medium
Unassigned

Bug Description

Needing to use "netplan set" for creating automatically a working netplan yaml file through BASH script.
The new 0.105 version of "netplan set" seems broken because its behaviour is different from 0.104 version and the output changes with the original content of output yaml file.
Some fields like ip addresses are always added instead of overwritten.
Other fields like routes fail to be modified if existing in output file.
It adds unnecessary double quotes to values, possibly breaking 3rd party parsers

- The 0.105 "netplan set" command surrounds ip addresses, routes, subnets and the "default" word with double quotes even if not necessary.
  The previous 0.104 "netplan set" command did not add those double quotes.
  The presence of unexpected double quotes could break compatibility of existing yaml file parsers made by 3rd party.

- The 0.105 "netplan set" command keeps adding new ip addresses instead of overwriting old ones.
  The previous 0.104 "netplan set" command always overwrite the existing ip addresses.

- The 0.105 "netplan set" command when working on an existing yaml file with an interface WITH routes fails to add and/or overwrite existing routes with no error or message.
  The previous 0.104 "netplan set" command always overwrite the existing routes.

In attachment the output of the same command run either in 0.104 (Ubuntu 20.04.5 LTS) and in 0.105 (Ubuntu 22.04.2 LTS)

Revision history for this message
Leonardo Saccardi (lsaccardi78) wrote :
Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

Hi Leonardo,

The Netplan's parser went through a major refactoring between versions 0.104 and 0.105. That's probably what caused the behavioral change you've found.

I believe that what is not very clear is what the expected outcome of "netplan set" is. Netplan naturally merges the configuration when the same interface is defined in two different places. So when you introduce a new IP address with netplan set, as I understand, it should add it to the existing list of IPs. That said, the new behavior seems to be correct.

Now, it should do the same for routes. It is a bug that was already fixed [0] in Netplan 0.106 (available only in Lunar at the moment).

If you want to overwrite the old entries you need to do something like this:

netplan set "network.ethernets.ens160.routes=null"

And then add the new route.

Regarding the extra quotes, that's unfortunate it will add them when you didn't use them yourself. But I don't expect it to break YAML parsers out there because it's part of the YAML specification [1].

I think the next steps here are 1) update netplan-set(8) to make it clear what the expected behavior of "netplan set" is; and 2) think about back-porting [0] to Netplan 0.105 so it will behave as expected when updating routes.

[0] - https://github.com/canonical/netplan/pull/320
[1] - https://yaml.org/spec/1.1/#id858081

Lukas Märdian (slyon)
Changed in netplan:
status: New → Triaged
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.