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

Top-level 'network' key results in error using v2 config #3815

Closed
ubuntu-server-builder opened this issue May 12, 2023 · 6 comments
Closed
Labels
launchpad Migrated from Launchpad priority Fix soon

Comments

@ubuntu-server-builder
Copy link
Collaborator

This bug was originally filed in Launchpad as LP: #1906187

Launchpad details
affected_projects = ['cloud-init (Ubuntu)', 'netplan.io (Ubuntu)']
assignee = None
assignee_name = None
date_closed = 2022-05-18T16:51:35.627900+00:00
date_created = 2020-11-29T21:45:28.567511+00:00
date_fix_committed = 2022-05-17T19:02:05.492006+00:00
date_fix_released = 2022-05-18T16:51:35.627900+00:00
id = 1906187
importance = high
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1906187
milestone = None
owner = falcojr
owner_name = James Falcon
private = False
status = fix_released
submitter = chris1294832
submitter_name = Christian Dohm
tags = []
duplicates = []

Launchpad user Christian Dohm(chris1294832) wrote on 2020-11-29T21:45:28.567511+00:00

I've created a 'network-config' file with Terraform's yamldecode() function that contains (btw. I've tried with the version being a Number w/o quotes and as well as a String as shown here):

"network":
  "ethernets":
    "eth0":
      "gateway4": "192.168.1.1"
      "nameservers":
        "addresses":
        - "192.168.1.74"
        - "192.168.1.104"
        "search":
        - "fritz.box"
      "set-name": "eth0"
  "version": "2"

After running on Raspberry Pi 4B with 4 GB, created with ubuntu-20.04.1-preinstalled-server-arm64+raspi.img.xz, the machine's setup fails and /var/log/cloud-init.log reveals that:

2020-04-01 17:23:48,649 - util.py[DEBUG]: Reading from /boot/firmware//network-config (quiet=False)
2020-04-01 17:23:48,649 - util.py[DEBUG]: Read 245 bytes from /boot/firmware//network-config
2020-04-01 17:23:48,650 - util.py[DEBUG]: Attempting to load yaml from string of length 240 with allowed root types (<class 'dict'>,)
2020-04-01 17:23:48,652 - util.py[DEBUG]: Attempting to load yaml from string of length 245 with allowed root types (<class 'dict'>,)
2020-04-01 17:23:48,656 - DataSourceNoCloud.py[DEBUG]: Top level network key in network-config but missing 'config' or 'version': {'network': {'ethernets': {'eth0': {'gateway4': '192.168.1.1', 'nameservers': {'addresses': ['192.168.1.74', '192.168.1.104'], 'search': ['fritz.box']}, 'set-name': 'eth0'}}, 'version': '2'}}

The corresponding /var/log/clout-init-output.log reveals the trace and that Network won't come up.

Cloud-init v. 20.2-45-g5f7825e2-0ubuntu1~20.04.1 running 'init-local' at Wed, 01 Apr 2020 17:23:48 +0000. Up 21.71 seconds.
2020-04-01 17:23:48,796 - util.py[WARNING]: failed stage init-local
failed run of stage init-local

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 653, in status_wrapper
    ret = functor(name, args)
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 362, in main_init
    init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))
  File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 699, in apply_network_config
    net.wait_for_physdevs(netcfg)
  File "/usr/lib/python3/dist-packages/cloudinit/net/init.py", line 523, in wait_for_physdevs
    physdevs = extract_physdevs(netcfg)
  File "/usr/lib/python3/dist-packages/cloudinit/net/init.py", line 519, in extract_physdevs
    raise RuntimeError('Unknown network config version: %s' % version)
RuntimeError: Unknown network config version: None

Cloud-init v. 20.2-45-g5f7825e2-0ubuntu1~20.04.1 running 'init' at Wed, 01 Apr 2020 17:23:50 +0000. Up 23.69 seconds.
ci-info: +++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++
ci-info: +--------+-------+-----------+-----------+-------+-------------------+
ci-info: | Device | Up | Address | Mask | Scope | Hw-Address |
ci-info: +--------+-------+-----------+-----------+-------+-------------------+
ci-info: | eth0 | False | . | . | . | dc:a6:32:b1:78:8e |
ci-info: | lo | True | 127.0.0.1 | 255.0.0.0 | host | . |
ci-info: | lo | True | ::1/128 | . | host | . |
ci-info: | wlan0 | False | . | . | . | dc:a6:32:b1:78:8f |
ci-info: +--------+-------+-----------+-----------+-------+-------------------+
ci-info: +++++++++++++++++++Route IPv6 info+++++++++++++++++++
ci-info: +-------+-------------+---------+-----------+-------+
ci-info: | Route | Destination | Gateway | Interface | Flags |
ci-info: +-------+-------------+---------+-----------+-------+
ci-info: +-------+-------------+---------+-----------+-------+
2020-04-01 17:23:50,653 - stages.py[WARNING]: Failed to rename devices: Failed to apply network config names: Unknown network config version: None

Related bugs:

  • bug 1798117: juju sends "network" top level key to user.network-config in lxd containers
@ubuntu-server-builder ubuntu-server-builder added launchpad Migrated from Launchpad priority Fix soon labels May 12, 2023
@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Christian Dohm(chris1294832) wrote on 2020-11-29T22:09:12.179620+00:00

Should be yamlencode(), it also happens with ubuntu-20.10-preinstalled-server-arm64+raspi.img.xz

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Ryan Harper(raharper) wrote on 2020-11-30T15:37:16+00:00

Public bug reported:

Thank you for filing a bug.

I've created a 'network-config' file with Terraform's yamldecode() function that contains (btw. I've tried with the version being a Number w/o quotes and as well as a String as shown here):

"network":
"ethernets":
"eth0":
"gateway4": "192.168.1.1"
"nameservers":
"addresses":
- "192.168.1.74"
- "192.168.1.104"
"search":
- "fritz.box"
"set-name": "eth0"
"version": "2"

After running on Raspberry Pi 4B with 4 GB, created with ubuntu-20.04.1-preinstalled-server-arm64+raspi.img.xz, the machine's setup fails and /var/log/cloud-init.log reveals that:

2020-04-01 17:23:48,649 - util.py[DEBUG]: Reading from /boot/firmware//network-config (quiet=False)
2020-04-01 17:23:48,649 - util.py[DEBUG]: Read 245 bytes from /boot/firmware//network-config
2020-04-01 17:23:48,650 - util.py[DEBUG]: Attempting to load yaml from string of length 240 with allowed root types (<class 'dict'>,)
2020-04-01 17:23:48,652 - util.py[DEBUG]: Attempting to load yaml from string of length 245 with allowed root types (<class 'dict'>,)
2020-04-01 17:23:48,656 - DataSourceNoCloud.py[DEBUG]: Top level network key in network-config but missing 'config' or 'version': {'network': {'ethernets': {'eth0': {'gateway4': '192.168.1.1', 'nameservers': {'addresses': ['192.168.1.74', '192.168.1.104'], 'search': ['fritz.box']}, 'set-name': 'eth0'}}, 'version': '2'}}

This happens due to the _maybe_remove_top_network method which only
understood network-config v1 format. If the config provided included
the 'network' key, it would remove it. It does some additional
checks (for v1 only) and if they don't match it returns the config
as it was loaded; in this case, with the top-level 'network' key.

Then this network config is passed to cloudinit.net which expects
the DataSource's .network_config property to include a config without a
'network' key; however, in this case, it still has the top-level key
and this confuses the .net's extract_physdevs function.

We should fix _maybe_remove_top_network to handle either v1 or v2;
We may want to accept version field as string and attempt to int() the
value.

As a workaround, if you specify your network config version 2 with the
following changes:

  1. remove 'network' key
  2. use integer 2 in the 'version' field
  3. optionally, your 'set-name' requires use of a 'match' attribute,
    otherwise it's ignored.

set-name: eth0
match:
macaddress: 'AA:BB:CC:DD:EE:FF'

This should let you progress.

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Launchpad Janitor(janitor) wrote on 2021-04-19T23:03:48.964839+00:00

Status changed to 'Confirmed' because the bug affects multiple users.

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user James Falcon(falcojr) wrote on 2022-05-17T19:02:25.158035+00:00

Fix committed at #1417

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Brett Holman(holmanb) wrote on 2022-05-18T16:51:36.518080+00:00

This bug is believed to be fixed in cloud-init in version 22.2. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Launchpad Janitor(janitor) wrote on 2022-05-19T06:25:47.811570+00:00

This bug was fixed in the package cloud-init - 22.2-0ubuntu1~22.10.1


cloud-init (22.2-0ubuntu1~22.10.1) kinetic; urgency=medium

-- Brett Holman brett.holman@canonical.com Wed, 18 May 2022 11:23:42 -0600

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
launchpad Migrated from Launchpad priority Fix soon
Projects
None yet
Development

No branches or pull requests

1 participant