Page MenuHomeVyOS Platform

Bug in cloud-init when MTU in network_data.json is set to 'null'
Open, NormalPublicBUG

Description

Summary: SSH keys etc do not get set correctly due to incorrect MTU handling.

When network_data.json gets downloaded from cloud-init, eg. http://169.254.169.254/openstack/2018-08-27/network_data.json
The 'links' node might contain an mtu that is set to 'null'
This documented in the following Openstack document, https://docs.openstack.org/nova/latest/user/metadata.html
Ideally Openstack should return the correct MTU, but in my environment it does not.

VyOS does not like this and the cc_vyos.py script returns an error.

See the following error:

2024-03-08 16:18:20,552 - cc_vyos.py[DEBUG]: Configured SSH public key for user: vyos
2024-03-08 16:18:20,552 - cc_vyos.py[DEBUG]: Configuring network using Cloud-init networking config version 1
2024-03-08 16:18:20,552 - cc_vyos.py[DEBUG]: Setting MAC for eth0: xx:xx:xx:xx:xx:xx
2024-03-08 16:18:20,552 - cc_vyos.py[DEBUG]: Setting MTU for eth0: None
2024-03-08 16:18:20,557 - handlers.py[DEBUG]: finish: modules-config/config-vyos: FAIL: running config-vyos with frequency once-per-instance
2024-03-08 16:18:20,557 - util.py[WARNING]: Running module vyos (<module 'cloudinit.config.cc_vyos' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_vyos.py'>) failed
2024-03-08 16:18:20,558 - util.py[DEBUG]: Running module vyos (<module 'cloudinit.config.cc_vyos' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_vyos.py'>) failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 1087, in _run_modules
    run_name, mod.handle, func_args, freq=freq
  File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 55, in run
    return self._runners.run(name, functor, args, freq, clear_on_fail)
  File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 185, in run
    results = functor(*args)
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_vyos.py", line 1158, in handle
    set_config_interfaces_v1(config, interface_config)
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_vyos.py", line 470, in set_config_interfaces_v1
    set_ether_mtu(config, iface_name, iface_config['mtu'])
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_vyos.py", line 275, in set_ether_mtu
    if max_mtu and max_mtu < mtu:
TypeError: '<' not supported between instances of 'int' and 'NoneType'
2024-03-08 16:18:20,558 - stages.py[DEBUG]: Running module write_files (<module 'cloudinit.config.cc_write_files' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_write_files.py'>) with frequency once-per-instance

This causes the SSH keys and other parts of the user data to not get set correctly, which results in you being unable to log in to the router after re-deploy.

I have worked around this error myself by commenting line 470 in https://github.com/vyos/vyos-cloud-init/blob/equuleus/cloudinit/config/cc_vyos.py#L470
and just letting DEFAULT_ETH_MTU of 1500 be set instead.

This is clearly not intended behavior and needs to be fixed. The last working version I was upgrading from was 1.3.2.

Details

Difficulty level
Unknown (require assessment)
Version
1.3.4 to 1.3.6?
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)