Specifying "Global Static Routes" causes cloud-init to fail to parse instance metadata
#2,170 opened on 2023年8月4日
Repository metrics
- Stars
- (417 stars)
- PR merge metrics
- (PR metrics pending)
説明
/kind bug
What steps did you take and what happened: I tried to specify "global static routes" in a clusterclass as this field was available:
Upon inspecting instance-data.json, it appears the following instance metadata template was rendered correctly:
"network": {
"config": {
"ethernets": {
"id0": {
"addresses": [
"192.168.117.162/24"
],
"gateway4": "192.168.117.1",
"match": {
"macaddress": "00:50:56:81:da:4e"
},
"nameservers": {
"addresses": [
"192.168.117.1"
]
},
"set-name": "eth0",
"wakeonlan": true
}
},
"routes": [
{
"metric": 222,
"to": "8.8.8.8",
"via": "192.168.117.1"
}
],
"version": 2
}
But running journalctl reveals that cloud-init threw an exception upon finding "routes" in the network config.
Aug 04 23:32:34 berry-lg59h-z4nbt cloud-init[444]: [CLOUDINIT]2023-08-04 23:32:34,696 - util.py[DEBUG]: failed stage init-local
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/cloudinit/net/network_state.py", line 355, in parse_config_v2
handler = self.command_handlers[command_type]
KeyError: 'routes'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/cloudinit/cmd/main.py", line 767, in status_wrapper
ret = functor(name, args)
File "/usr/lib/python3.7/site-packages/cloudinit/cmd/main.py", line 433, in main_init
init.apply_network_config(bring_up=bring_up_interfaces)
File "/usr/lib/python3.7/site-packages/cloudinit/stages.py", line 943, in apply_network_config
netcfg, bring_up=bring_up
File "/usr/lib/python3.7/site-packages/cloudinit/distros/__init__.py", line 268, in apply_network_config
network_state = parse_net_config_data(netconfig, renderer=renderer)
File "/usr/lib/python3.7/site-packages/cloudinit/net/network_state.py", line 1103, in parse_net_config_data
nsi.parse_config(skip_broken=skip_broken)
File "/usr/lib/python3.7/site-packages/cloudinit/net/network_state.py", line 306, in parse_config
self.parse_config_v2(skip_broken=skip_broken)
File "/usr/lib/python3.7/site-packages/cloudinit/net/network_state.py", line 359, in parse_config_v2
) from e
RuntimeError: No handler found for command 'routes'
After reading https://cloudinit.readthedocs.io/en/latest/reference/network-config-format-v2.html#network-config-v2, it does not appear that "routes" was a valid key under "network".
Specifying "routes" per-device works as expected, however.
What did you expect to happen: Specifying global static routes should either be not supported or translated to a per-device setting somehow.
Anything else you would like to add:
I also tried this with Ubuntu, but the machine did not acquire an IP address so I was unable to SSH in to see the problem. I suspect that the network config was invalid and so it was unable to acquire the static IP set in the instance metadata.
Environment:
- Cluster-api-provider-vsphere version: v1.7.0
- Kubernetes version: (use
kubectl version): v1.26.5 - OS (e.g. from
/etc/os-release): Photon OS 3.0