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

Bug #1785275 reported by Tracy Meyers
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Medium
Unassigned

Bug Description

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'

+ if proto == 'none':
+ proto = 'static'
     if proto not in ('static', 'dhcp', 'dhcp6'):
         raise ValueError("Unexpected value for PROTO: %s" % proto)

Revision history for this message
Tracy Meyers (tracy-meyers) wrote :
Revision history for this message
Scott Moser (smoser) wrote :

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

Revision history for this message
Tracy Meyers (tracy-meyers) wrote :

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

Scott Moser (smoser)
summary: - cloud-init pre-networking fails if grub defines static ip
+ cloud-init pre-networking fails if kernel cmdline defines static ip
Revision history for this message
Kevin (kevindtimm) wrote :

Attached is a patch for this modification

Revision history for this message
Scott Moser (smoser) wrote :

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.

Changed in cloud-init:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Donny Davis (donny-g) wrote :

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'

Revision history for this message
Donny Davis (donny-g) wrote :

@kevindtimm

Re-implemented your patch here

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

Revision history for this message
Donny Davis (donny-g) wrote :

This bug should be closed with this commit landing

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

thanks to @oddbloke for fixing this issue.

Revision history for this message
Ryan Harper (raharper) wrote :
Changed in cloud-init:
status: Triaged → Fix Committed
Revision history for this message
Brett Holman (holmanb) wrote :

Fix released in 20.1

Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.