Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying "Global Static Routes" causes cloud-init to fail to parse instance metadata #2170

Open
flawedmatrix opened this issue Aug 4, 2023 · 2 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.

Comments

@flawedmatrix
Copy link
Contributor

flawedmatrix commented Aug 4, 2023

/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:

// Routes is a list of optional, static routes applied to the virtual
// machine.
// +optional
Routes []NetworkRouteSpec `json:"routes,omitempty"`

Upon inspecting instance-data.json, it appears the following instance metadata template was rendered correctly:

{{- if .Routes }}
routes:
{{- range .Routes }}
- to: "{{ .To }}"
via: "{{ .Via }}"
metric: {{ .Metric }}
{{- end }}
{{- end }}

"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
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 4, 2023
@sbueringer
Copy link
Member

/help

@k8s-ci-robot
Copy link
Contributor

@sbueringer:
This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/help

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants