canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
2.99k stars 883 forks source link

cloud-init pre-networking fails if kernel cmdline defines static ip #3219

Closed ubuntu-server-builder closed 1 year ago

ubuntu-server-builder commented 1 year ago

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

Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = 2023-03-23T20:10:35.581735+00:00
date_created = 2018-08-03T15:56:24.600284+00:00
date_fix_committed = 2020-02-03T19:49:14.301397+00:00
date_fix_released = 2023-03-23T20:10:35.581735+00:00
id = 1785275
importance = medium
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1785275
milestone = None
owner = tracy-meyers
owner_name = Tracy Meyers
private = False
status = fix_released
submitter = tracy-meyers
submitter_name = Tracy Meyers
tags = []
duplicates = []

Launchpad user Tracy Meyers(tracy-meyers) wrote on 2018-08-03T15:56:24.600284+00:00

cloud-init pre-networking fails when grub is configured to use a static IP with the 'autoconf' field set to 'none' (https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt).

Cloud provider: vsphere

Static IP is configured here (/etc/default/grub).

https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt

off or none: don't use autoconfiguration (do static IP assignment instead)

GRUB_CMDLINE_LINUX=ip=10.121.105.37::10.121.104.1:255.255.252.0::eth0:none

Error: File "/usr/lib/python3/dist-packages/cloudinit/net/cmdline.py", line 58, in _klibc_to_config_entry
raise ValueError("Unexpected value for PROTO: %s" % proto)
ValueError: Unexpected value for PROTO: none

Workarounds: Option 1. Change the grub config to use 'dhcp' even though it defines most of the fields statically GRUB_CMDLINE_LINUX=ip=10.121.105.37::10.121.104.1:255.255.252.0::eth0:dhcp

Option 2. Patch to normalize 'none' to 'static' (I'd guess there's a more proper fix further up the call) --- /usr/lib/python3/dist-packages/cloudinit/net/cmdline.py.orig 2018-08-03 15:44:11.204005997 +0000 +++ /usr/lib/python3/dist-packages/cloudinit/net/cmdline.py 2018-08-03 15:44:15.448006149 +0000 @@ -52,6 +52,8 @@ else: proto = 'static'

ubuntu-server-builder commented 1 year ago

Launchpad user Tracy Meyers(tracy-meyers) wrote on 2018-08-03T15:56:24.600284+00:00

Launchpad attachments: cloud-init.tar.gz

ubuntu-server-builder commented 1 year ago

Launchpad user Scott Moser(smoser) wrote on 2018-08-03T16:45:02.673215+00:00

You mention 'grub', is this at all specific to grub? or is this just kernel command line specific.

ubuntu-server-builder commented 1 year ago

Launchpad user Tracy Meyers(tracy-meyers) wrote on 2018-08-03T17:52:06.746687+00:00

Kernel command line specific as documented here https://www.kernel.org/doc/Documentation/admin-guide/kernel-parameters.txt. I just configure this via grub.

ubuntu-server-builder commented 1 year ago

Launchpad user Kevin(kevindtimm) wrote on 2018-08-29T20:47:52.179370+00:00

Attached is a patch for this modification Launchpad attachments: 0001-change-none-to-static-for-ip-address-in-GRUB_CMDLINE.patch

ubuntu-server-builder commented 1 year ago

Launchpad user Scott Moser(smoser) wrote on 2018-09-06T14:08:25.457368+00:00

Hi, To contribute to cloud-init, please follow the HACKING.rst doc. You can view it online at https://cloudinit.readthedocs.io/en/latest/topics/hacking.html

Please let me know ifyou have any questions.

With respect to comments on the patch, we'd want to have a unit test that pushes the code through this path. If you have questions or need help, please feel free to ask.

ubuntu-server-builder commented 1 year ago

Launchpad user Donny Davis(donny-g) wrote on 2019-12-21T02:37:33.258301+00:00

it would be really great for pxe-less enviroments to fix this issue. MaaS has no method to operate in environments without dhcp without this patch.

MaaS is capable of adding in the proper kernel command line options, however cloud-init pukes when it doesn't get dhcp or static as a variable.

maas $PROFILE tags create name=$TAG comment='static addr' kernel_opts='ip=192.168.1.10::192.168.1.1:255.255.255.0::eth0:none'

ubuntu-server-builder commented 1 year ago

Launchpad user Donny Davis(donny-g) wrote on 2019-12-30T15:35:42.276729+00:00

@kevindtimm

Re-implemented your patch here

https://github.com/canonical/cloud-init/pull/148

ubuntu-server-builder commented 1 year ago

Launchpad user Donny Davis(donny-g) wrote on 2020-02-02T02:08:29.951659+00:00

This bug should be closed with this commit landing

https://github.com/canonical/cloud-init/pull/201

thanks to @oddbloke for fixing this issue.

ubuntu-server-builder commented 1 year ago

Launchpad user Ryan Harper(raharper) wrote on 2020-02-03T19:49:12.359245+00:00

https://github.com/canonical/cloud-init/pull/201/commits/b78742de6f2e2579118dfb8307e99fe7cb58fa00

ubuntu-server-builder commented 1 year ago

Launchpad user Brett Holman(holmanb) wrote on 2023-03-23T20:10:32.602048+00:00

Fix released in 20.1