cloud-init mangles sources.lists if mirror can't be found

Bug #1145215 reported by Ben Howard
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)
Fix Released
Medium
Unassigned
Precise
Fix Released
Low
Unassigned

Bug Description

On freshly build non-EC2 boot the system came up with out a useable apt sources.list.

Mar 4 20:54:02 vhost0761 [CLOUDINIT] cc_apt_pipelining.py[DEBUG]: Wrote /etc/apt/apt.conf.d/90cloud-init-pipelining with APT pipeline setting
Mar 4 20:54:02 vhost0761 [CLOUDINIT] __init__.py[DEBUG]: handling apt-update-upgrade with freq=None and args=[]
Mar 4 20:54:02 vhost0761 [CLOUDINIT] util.py[DEBUG]: Traceback (most recent call last):#012 File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_apt_update_upgrade.py", line 261, in find_apt_mirror_info#012 pmirrors = cfg['system_info']['package_mirrors']#012KeyError: 'system_info'
Mar 4 20:54:02 vhost0761 [CLOUDINIT] cc_apt_update_upgrade.py[WARNING]: Failed to get mirror info, falling back to default
Mar 4 20:54:02 vhost0761 [CLOUDINIT] cc_apt_update_upgrade.py[DEBUG]: mirror info: {'mirror': 'http://ibm.cloud.archive.ubuntu.com', 'primary': 'http://ibm.cloud.archive.ubuntu.com', 'ubuntu': {'security': 'http://security.ubuntu.com/ubuntu', 'primary': 'http://archive.ubuntu.com/ubuntu'}}
Mar 4 20:54:02 vhost0761 [CLOUDINIT] __init__.py[WARNING]: Traceback (most recent call last):#012 File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 117, in run_cc_modules#012 cc.handle(name, run_args, freq=freq)#012 File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/__init__.py", line 78, in handle#012 [name, self.cfg, self.cloud, cloudinit.log, args])#012 File "/usr/lib/python2.7/dist-packages/cloudinit/__init__.py", line 326, in sem_and_run#012 func(*args)#012 File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_apt_update_upgrade.py", line 51, in handle#012 generate_sources_list(release, mirrors)#012 File "/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_apt_update_upgrade.py", line 157, in generate_sources_list#012 util.render_to_file('sources.list', '/etc/apt/sources.list', params)#012 File "/usr/lib/python2.7/dist-packages/cloudinit/util.py", line 245, in render_to_file#012 f.write(t.respond())#012 File "_etc_cloud_templates_sources_list_tmpl.py", line 230, in respond#012NotFound: cannot find 'security'
Mar 4 20:54:02 vhost0761 [CLOUDINIT] __init__.py[ERROR]: config handling of apt-update-upgrade, None, [] failed
Mar 4 20:54:02 vhost0761 [CLOUDINIT] __init__.py[DEBUG]: handling landscape with freq=None and args=[]

Revision history for this message
Ben Howard (darkmuggle-deactivatedaccount) wrote :

root@vhost0761:/etc/apt# ll
total 64
drwxr-xr-x 6 root root 4096 Mar 4 20:59 ./
drwxr-xr-x 87 root root 4096 Mar 4 20:53 ../
drwxr-xr-x 2 root root 4096 Mar 4 07:06 apt.conf.d/
drwxr-xr-x 2 root root 4096 Apr 20 2012 preferences.d/
-rw-r--r-- 1 root root 0 Mar 4 20:54 sources.list
drwxr-xr-x 2 root root 4096 Mar 4 19:38 sources.list.d/
-rw-r--r-- 1 root root 261 Mar 4 19:38 sources.list.save
-rw------- 1 root root 1200 Mar 4 07:04 trustdb.gpg
-rw-r--r-- 1 root root 12698 Mar 4 19:38 trusted.gpg
-rw-r--r-- 1 root root 12335 Mar 4 07:04 trusted.gpg~

Revision history for this message
Scott Moser (smoser) wrote :

--- cloudinit/CloudConfig/cc_apt_update_upgrade.py 2013-01-16 22:19:13 +0000
+++ cloudinit/CloudConfig/cc_apt_update_upgrade.py 2013-03-04 21:23:28 +0000
@@ -221,10 +221,8 @@

     # this is used if cfg['system_info']['package_mirrors'] is not present
     def_mirror_info = {
- 'ubuntu': {
- 'primary': "http://archive.ubuntu.com/ubuntu",
- 'security': "http://security.ubuntu.com/ubuntu"
- }
+ 'primary': "http://archive.ubuntu.com/ubuntu",
+ 'security': "http://security.ubuntu.com/ubuntu"
     }
     mirror = None

That looks like the fix, but I suspect that your /etc/cloud/cloud.cfg has been locally modified as the packaged version should provide a ['system_info']['package_mirrors'] entry that would make the above code irrelevant (which is why it doesn't fail elsewhere, i think).

Scott Moser (smoser)
Changed in cloud-init (Ubuntu):
status: New → Fix Released
Changed in cloud-init (Ubuntu Precise):
status: New → Triaged
importance: Undecided → Low
Changed in cloud-init (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Adam Conrad (adconrad) wrote : Please test proposed package

Hello Ben, or anyone else affected,

Accepted cloud-init into precise-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/cloud-init/0.6.3-0ubuntu1.6 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in cloud-init (Ubuntu Precise):
status: Triaged → Fix Committed
tags: added: verification-needed
Revision history for this message
Ben Howard (darkmuggle-deactivatedaccount) wrote :

Marking verification done. Verified that is fixed.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 0.6.3-0ubuntu1.6

---------------
cloud-init (0.6.3-0ubuntu1.6) precise-proposed; urgency=low

  * debian/patches/rework-mirror-selection.patch: update patch to
    address issue if package_mirrors is missing from cloud.cfg (LP: #1145215)
  * debian/patches/lp-1202202-azure-datasource.patch: add azure datasource
    backported from trunk (LP: #1202202)
  * debian/patches/future_utils.patch: pull back some upstream 'util' functions
    for use in the azure datasource.
  * debian/cloud-init.templates: add 'Azure' to the list of choices
    for cloud-init/datasources.
 -- Scott Moser <email address hidden> Wed, 14 Aug 2013 14:36:41 -0400

Changed in cloud-init (Ubuntu Precise):
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.