Upgrade corrupts 90_dpkg.cfg

Bug #1841697 reported by Dan Peschman on 2019-08-28
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)
Medium
Unassigned

Bug Description

Upgrading cloud-init to version 19.1-1-gbaa47854-0ubuntu1~16.04.1 on Ubuntu 16.04.6 LTS corrupts /etc/cloud/cloud.cfg.d/90_dpkg.cfg by adding an extra bracket "]" to the datasource_list:

//////////////// bash
# Initial state
root@ub:/home/dan# cat /etc/cloud/cloud.cfg.d/90_dpkg.cfg
datasource_list: [ConfigDrive, None]

# I run a reinstall here because I'm already on the latest version,
# but the same thing happens when upgrading from an old version.
root@ub:/home/dan# apt-get install --reinstall cloud-init
...
Preparing to unpack .../cloud-init_19.1-1-gbaa47854-0ubuntu1~16.04.1_all.deb ...
Unpacking cloud-init (19.1-1-gbaa47854-0ubuntu1~16.04.1) over (19.1-1-gbaa47854-0ubuntu1~16.04.1) ...
Processing triggers for ureadahead (0.100.0-19.1) ...
Setting up cloud-init (19.1-1-gbaa47854-0ubuntu1~16.04.1) ...
Leaving 'diversion of /etc/init/ureadahead.conf to /etc/init/ureadahead.conf.disabled by cloud-init'

# End state
root@ub:/home/dan# cat /etc/cloud/cloud.cfg.d/90_dpkg.cfg
# to update this file, run dpkg-reconfigure cloud-init
datasource_list: [ ConfigDrive, None] ]

# The extra bracket causes file loading to fail and ConfigDrive to not be used on future boots.
# From /var/log/cloud-init-output.log:

2019-08-27 20:56:54,194 - util.py[WARNING]: Failed loading yaml blob. Invalid format at line 2 column 1: "while parsing a block mapping
  in "<unicode string>", line 2, column 1:
    datasource_list: [ ConfigDrive, ...
    ^
expected <block end>, but found ']'
  in "<unicode string>", line 2, column 39:
     ... urce_list: [ ConfigDrive, None] ]
                                         ^"

Related branches

Ryan Harper (raharper) wrote :

Thanks for filing a bug.

I can recreate this using your config file. It appears to be related to the shell parsing of that value, if you leave a space before the start of the list and the end like so:

diff -u /etc/cloud/cloud.cfg.d/90_dpkg.cfg.bad /etc/cloud/cloud.cfg.d/90_dpkg.cfg
--- /etc/cloud/cloud.cfg.d/90_dpkg.cfg.bad 2019-08-28 01:28:14.064394783 +0000
+++ /etc/cloud/cloud.cfg.d/90_dpkg.cfg 2019-08-28 01:26:12.279439013 +0000
@@ -1,2 +1,2 @@
 # to update this file, run dpkg-reconfigure cloud-init
-datasource_list: [ConfigDrive, None]
+datasource_list: [ ConfigDrive, None ]

I believe this is due to manual modification of the file, correct?

Changed in cloud-init (Ubuntu):
importance: Undecided → Medium
status: New → Incomplete
Ryan Harper (raharper) wrote :

The cloud-init.config dpkg parser has this sed line which doesn't like the brackets without spaces:

sed -n -e /^datasource_list:/!d -e s/datasource_list:[ \[]*// -e s, \]$,, -e p /etc/cloud/cloud.cfg.d/90_dpkg.cfg

Dan Peschman (dpeschman) wrote :

That’s right - we write the file manually.

Ryan Harper (raharper) wrote :

As a workaround, you can ensure that you have a space before and after the list:

datasource_list: [ ConfigDrive, None ]

Ryan Harper (raharper) on 2019-08-28
Changed in cloud-init (Ubuntu):
status: Incomplete → In Progress
Dan Peschman (dpeschman) wrote :

Thanks. We've implemented that workaround and are rebuilding our images now.

This bug is fixed with commit 8bded9f0 to cloud-init on branch ubuntu/devel.
To view that commit see the following URL:
https://git.launchpad.net/cloud-init/commit/?id=8bded9f0

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers