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

Bug #1785275 reported by Tracy Meyers on 2018-08-03
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cloud-init
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)

Tracy Meyers (tracy-meyers) wrote :
Scott Moser (smoser) wrote :

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

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) on 2018-08-03
summary: - cloud-init pre-networking fails if grub defines static ip
+ cloud-init pre-networking fails if kernel cmdline defines static ip
Kevin (kevindtimm) wrote :

Attached is a patch for this modification

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
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers