Upgrade corrupts 90_dpkg.cfg

Bug #1841697 reported by Dan Peschman
22
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)
Fix Released
Medium
Ryan Harper
Eoan
Fix Released
Medium
Ryan Harper

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

Revision history for this message
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
Revision history for this message
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

Revision history for this message
Dan Peschman (dpeschman) wrote :

That’s right - we write the file manually.

Revision history for this message
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)
Changed in cloud-init (Ubuntu):
status: Incomplete → In Progress
Revision history for this message
Dan Peschman (dpeschman) wrote :

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

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

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

Chad Smith (chad.smith)
Changed in cloud-init (Ubuntu):
status: In Progress → Fix Released
assignee: nobody → Ryan Harper (raharper)
status: Fix Released → Fix Committed
Changed in cloud-init (Ubuntu Eoan):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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