cannot disable cloud-init networking despite trying hard

Bug #1862702 reported by Dimitri John Ledkov
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)
Fix Released
Medium
Chad Smith

Bug Description

$ cat /proc/cmdline
network-config={config:disabled} ip=10.245.236.14::10.245.236.1:255.255.255.0:s1lp14:encc000.2653:none:10.245.236.1 vlan=encc000.2653:encc000 url=ftp://10.13.0.2:21/ubuntu-live-server-20.04/focal-live-server-s390x.iso --- quiet

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 678, in apply_network_config
    netcfg, src = self._find_networking_config()
  File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 637, in _find_networking_config
    NetworkConfigSource.cmdline: cmdline.read_kernel_cmdline_config(),
  File "/usr/lib/python3/dist-packages/cloudinit/net/cmdline.py", line 276, in read_kernel_cmdline_config
    return util.load_yaml(_b64dgz(data64))
  File "/usr/lib/python3/dist-packages/cloudinit/net/cmdline.py", line 256, in _b64dgz
    blob = base64.b64decode(b64str)
  File "/usr/lib/python3.7/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

$ dpkg -l | grep cloud-init
ii cloud-init 19.4-56-g06e324ff-0ubuntu1 all initialization and customization tool for cloud instances

However:

$ cat /proc/cmdline
network-config=e2NvbmZpZzogZGlzYWJsZWR9 ip=10.245.236.14::10.245.236.1:255.255.255.0:s1lp14:encc000.2653:none:10.245.236.1 vlan=encc000.2653:encc000 url=ftp://10.13.0.2:21/ubuntu-live-server-20.04/focal-live-server-s390x.iso --- quiet

works fine (i.e. b64encoded)

This is on s390x

Tags: s390x
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

I also have

network:
  config: disabled

in /etc/cloud/cloud.cfg but it is ignored.

Revision history for this message
Dan Watkins (oddbloke) wrote :

Hey Dimitri, can you run `cloud-init collect-logs` on an affected instance, attach the tarball here, and then move this back to New, please? Thanks!

Changed in cloud-init (Ubuntu):
status: New → Incomplete
Revision history for this message
Ryan Harper (raharper) wrote :

The kernel cmdline reader for network-config= expects base64 input, however documentation suggests that network-config is *optionally* base64 encoded.

Disabling Network Configuration
===============================

Users may disable `Cloud-init`_ 's network configuration capability and rely
on other methods, such as embedded configuration or other customizations.

`Cloud-init`_ supports the following methods for disabling cloud-init.

**Kernel Command Line**

`Cloud-init`_ will check for a parameter ``network-config`` and the
value is expected to be YAML string in the :ref:`network_config_v1` format.
The YAML string may optionally be ``Base64`` encoded, and optionally
compressed with ``gzip``.

Example disabling kernel command line entry: ::

  network-config={config: disabled}

This is incorrect; encoding to base64 is *required* and *gzipping* base64 is optional.

We could make the change to accept the disable config unencoded; I do think that would be
the nice thing to do; alternatively, we can update the documentation to have the example
already b64 encoded:

@Dimitri, the /etc/cloud config file is not reached; cloud-init reads the kernel cmdline first and fails.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

ok.

I'd like to have a non-base64/non-gzipped way to disable the networking

and I first tried just the /etc/cloud snippet of network disabled, but that didn't work because I also had ip= on the kernel command line, and cloud-init still did automatic built-in network discover.

Are the /etc/cloud files ignored, if there is ip= vlan= specification on the kernel command line? (which cloud-init fails to parse and maintain correctly)

I'm stuck between this bug and https://bugs.launchpad.net/cloud-init/+bug/1861460

Chad Smith (chad.smith)
Changed in cloud-init (Ubuntu):
status: Incomplete → Triaged
assignee: nobody → Chad Smith (chad.smith)
importance: Undecided → Medium
Revision history for this message
Chad Smith (chad.smith) wrote :

Upstream branch put up that will allow network-config=disabled as kernel cmdline

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

Changed in cloud-init (Ubuntu):
status: Triaged → Won't Fix
status: Won't Fix → In Progress
Revision history for this message
Chad Smith (chad.smith) wrote :

An upstream commit just landed with this changeset https://github.com/canonical/cloud-init/commit/1d2dfc5d879dc905f440697c2b805c9485dda821

It will make it into Ubuntu Focal images this week.

Changed in cloud-init (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Chad Smith (chad.smith) wrote :

A version of cloud-init containing this fix was published to Ubuntu Focal (20.04) cloud-init 20.1-9-g1f860e5a-0ubuntu1.

If this is still a problem for you, please re-open this bug or submit a new bug with related context.

Changed in cloud-init (Ubuntu):
status: Fix Committed → Fix Released
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.