cloud-init 0.6.3 on precise generates invalid apt-get install command line

Bug #1456989 reported by Dimiter Naydenov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
juju-core
Fix Released
High
Dimiter Naydenov
1.24
Fix Released
High
Dimiter Naydenov

Bug Description

Since the CentOS support landed on 1.24, I observed a regression when adding a precise machine in an environment (not when bootstrapping on precise). Looking at the cloud-init-output.log of the precise machine I can see the following:

E: Command line option --target-release precise-updates/cloud-tools cloud-utils is not understood
2015-05-19 15:29:47,184 - cc_apt_update_upgrade.py[WARNING]: Failed to install packages: ['curl', 'cpu-checker', 'bridge-utils', 'rsyslog-gnutls', '--target-release precise-updates/cloud-tools cloud-utils', '--target-release precise-updates/cloud-tools cloud-image-utils', 'tmux']
2015-05-19 15:29:47,188 - __init__.py[WARNING]: Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 117, in run_cc_modules
    cc.handle(name, run_args, freq=freq)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 78, in handle
    [name, self.cfg, self.cloud, cloudinit.log, args])
  File "/usr/lib/python2.7/dist-packages/cloudinit/__init__.py", line 327, in sem_and_run
    func(*args)
  File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_apt_update_upgrade.py", line 126, in handle
    raise errors[0]
CalledProcessError: Command '['apt-get', '--option', 'Dpkg::Options::=--force-confold', '--assume-yes', 'install', 'curl', 'cpu-checker', 'bridge-utils', 'rsyslog-gnutls', '--target-release precise-updates/cloud-tools cloud-utils', '--target-release precise-updates/cloud-tools cloud-image-utils', 'tmux']' returned non-zero exit status 100

2015-05-19 15:29:47,188 - __init__.py[ERROR]: config handling of apt-update-upgrade, None, [] failed

2015-05-19 15:29:47,200 - cloud-init-cfg[ERROR]: errors running cloud_config [config]: ['apt-update-upgrade']
errors running cloud_config [config]: ['apt-update-upgrade']

This is caused by rendering user-data YAML with the following in the "packages" section:

packages:
- curl
- cpu-checker
- bridge-utils
- rsyslog-gnutls
- --target-release precise-updates/cloud-tools cloud-utils
- --target-release precise-updates/cloud-tools cloud-image-utils
- tmux

The problem is that cloud-init 0.6.3 (in precise) encloses each of the packages in the list in single quotes (see above), which leads to an invalid argument like '--target-release precise-updates/cloud-tools cloud-utils' to apt-get install.
I have already fixed this some time ago (see https://github.com/juju/juju/pull/1670 and the related bug 1424777 which this fixes), but after https://github.com/juju/juju/pull/2066 has landed my fix seems to have disappeared.

The proper fix (still live testing, but looks fine so far) needs to:
1. In cloudconfg/cloudinit/cloudinit_ubuntu.go, addRequiredPackages() where we add packages to install, and for cloud-tools packages, add "--target-release", "precise-updates/cloud-tools", and the package name separately as "packages".
2. In the same file, but in getCommandsForAddingPackages(), where we loop over the cfg.Packages() list, ensure we treat "packages" named "--target-release" and the two following entries as separate arguments to pass to InstallCmd below (effectively undoing what was done in step 1).

Revision history for this message
Dimiter Naydenov (dimitern) wrote :

1.23 is not affected, but both 1.24 and 1.25 are.

Revision history for this message
Dimiter Naydenov (dimitern) wrote :

Here's the patch I'm using so far. Live tests on MAAS so far work fine with it (bootstrapping on precise and deploying to trusty and vice versa).

Revision history for this message
Dimiter Naydenov (dimitern) wrote :
Changed in juju-core:
status: Triaged → In Progress
Revision history for this message
Dimiter Naydenov (dimitern) wrote :

Fix for 1.24 landed, for 1.25 - https://github.com/juju/juju/pull/2408

Changed in juju-core:
status: In Progress → Fix Committed
Curtis Hovey (sinzui)
tags: added: tech-debt
Curtis Hovey (sinzui)
Changed in juju-core:
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

Bug attachments

Remote bug watches

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