conversion from netplan (network v2) YAML to ENI format fails for 'default' routes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
As reported by a customer, when cloud-init converts netplan YAML to ENI format for older distros, it does not handle the new "default" route syntax. This is somewhat reproducible via the command line.
My test platform: 22.04.3 with cloud-init 23.3.3-
For example, with this input YAML:
network:
ethernets:
eno1:
addresses:
- 10.0.0.1/24
match:
macaddress: 11:22:33:44:55:66;
routes:
- to: default
via: 10.0.0.254
mtu: 1500
nameservers:
addresses:
- 10.0.0.254
search:
- example.com
version: 2
$ cloud-init devel net-convert -p test.yaml -k yaml -d ./test -D debian -O eni
2023-12-14 20:10:27,181 - network_
Traceback (most recent call last):
File "/usr/bin/
sys.
File "/usr/lib/
retval = util.log_time(
File "/usr/lib/
ret = func(*args, **kwargs)
File "/usr/lib/
ns = network_
File "/usr/lib/
nsi.
File "/usr/lib/
self.
File "/usr/lib/
handler(self, command)
File "/usr/lib/
subnets = self._v2_
File "/usr/lib/
_normalize_
File "/usr/lib/
_normalize_
File "/usr/lib/
raise ValueError(
ValueError: Address default is not a valid ip address
The expectation is of course a working default route in the files in ENI format. The deprecated "gateway4" syntax does work, as does modifying the input YAML to use "0.0.0.0/0" instead of "default". The latter substitution results, ironically, in an ENI file that uses "default":
$ cat ./test/
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/
# network: {config: disabled}
auto lo
iface lo inet loopback
dns-nameservers 10.0.0.254
dns-search example.com
auto eno1
iface eno1 inet static
address 10.0.0.1/24
dns-nameservers 10.0.0.254
dns-search example.com
dns {'nameservers': ['10.0.0.254'], 'search': ['example.com']}
mtu 1500
post-up route add default gw 10.0.0.254 || true
pre-down route del default gw 10.0.0.254 || true
I was able to reproduce this scenario, but the customer reports an additional behavior, possibly with older versions of cloud-init, where instead of failing entirely, the use of "default" resulted in an ENI file that had "default/0" instead of simply "default". This may have been fixed in more recent cloud-init versions, and the equivalent "gateway4" syntax also produces the correct result here.
In any event, the customer is also wondering whether or not the fix may be backported to older versions, as well as when support for the "gateway4" syntax will be entirely removed, since that is the workaround at the moment.
Thanks,
Dave
Canonical Support
summary: |
- conversion from netplan YAML to ENI format fails for 'default' routes + conversion from netplan (network v2) YAML to ENI format fails for + 'default' routes |
While the supplied config is valid netplan, it is not valid network v2 configuration: /cloudinit. readthedocs. io/en/latest/ reference/ network- config- format- v2.html
https:/
In order to render to ENI, valid v1 or v2 configuration must be used.
There are plans to add `to: default` v2 configuration syntax in the future. When that change happens, it will be backported to currently supported Ubuntu releases. Additionally, if the `gateway4` syntax is removed, it will only happen in a newer development release once `to: default` is supported, and that change will not be backported as it could break currently deployed installations.
Since the behavior is working as intended, I'm going to change the status to invalid, but if there are additional questions or concerns I didn't cover, we can discuss it here and I can reopen the issue if needed.