[SRU] ConfigDrive datasource fails when metadata files is null

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

Bug Description

SRU Justification

[IMPACT] On Ubuntu 12.04, cloud-init fails to provision when ConfigDrive data has a null value for "files". Instances are DOA.

[FIX] Cloud-init should check if "files" is a valid value.

[REGRESSION POTENTIAL] This change is low-risk as it is error-hardening.

[TEST CASES 1] :
1. Build new images from proposed
2. Boot image on Cloud with files as null
3. Boot image on Cloud with files populated
4. Check to make sure that cloud-init provisioned with out errors

[TEST CASE 2]:
1. Build existing Ubuntu image on ConfigDrive provisioned cloud
2. Check for any errors in the logs
3. Upgrade cloud-init
4. Reboot and check for errors in logs
5. Create a new instance from existing instance
6. Check for errors in the log.

[FROM ORIGINAL REPORT]

Sep 4 18:46:28 utl-precise-0904-88f2e9 [CLOUDINIT] __init__.py[WARNING]: get_data of DataSourceConfigDriveNet raised Failed to read file []: list indices must be integers, not str
Sep 4 18:46:28 utl-precise-0904-88f2e9 [CLOUDINIT] util.py[DEBUG]: Traceback (most recent call last):#012 File "/usr/lib/python2.7/dist-packages/cloudinit/__init__.py", line 215, in get_data_source#012 if s.get_data():#012 File "/usr/lib/python2.7/dist-packages/cloudinit/DataSourceConfigDrive.py", line 138, in get_data#012 results = read_config_drive_dir(self.seed_dir)#012 File "/usr/lib/python2.7/dist-packages/cloudinit/DataSourceConfigDrive.py", line 321, in read_config_drive_dir#012 data = finder(source_dir)#012 File "/usr/lib/python2.7/dist-packages/cloudinit/DataSourceConfigDrive.py", line 392, in read_config_drive_dir_v2#012 raise BrokenConfigDriveDir("Failed to read file %s: %s" % (item, exc))#012BrokenConfigDriveDir: Failed to read file []: list indices must be integers, not str
Sep 4 18:46:28 utl-precise-0904-88f2e9 [CLOUDINIT] __init__.py[DEBUG]: Did not find data source. searched classes: ['DataSourceConfigDriveNet']
root@utl-precise-0904-88f2e9:/#

meta_data.json:
{
    "domain": "foobar.com",
    "files": [
        []
    ],
    "hostname": "utl-precise-0904-88f2e9",
    "meta": {
        "dsmode": "net"
    },
    "name": "utl-precise-0904-88f2e9",
    "network_config": {
        "content_path": "/content/interfaces"
    },
    "public_keys": {
        "177313": "<REDACTED FOR READABILITY>"
    },
    "uuid": "9ba148b1-74d2-7f3f-2e8d-68746513d09f"
}

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

This bug only affects Ubuntu 12.04.

Changed in cloud-init (Ubuntu Precise):
status: New → In Progress
assignee: nobody → Ben Howard (utlemming)
Changed in cloud-init (Ubuntu):
status: New → Invalid
Revision history for this message
Ben Howard (darkmuggle-deactivatedaccount) wrote :

Simple patch fixes the problem:

--- cloud-init-0.6.3.orig/cloudinit/DataSourceConfigDrive.py
+++ cloud-init-0.6.3/cloudinit/DataSourceConfigDrive.py
@@ -380,7 +380,8 @@
     files = {}
     try:
         for item in results['metadata'].get('files', {}):
- files[item['path']] = read_content_path(item)
+ if len(item) > 0:
+ files[item['path']] = read_content_path(item)

         # the 'network_config' item in metadata is a content pointer
         # to the network config that should be applied.

Revision history for this message
Ben Howard (darkmuggle-deactivatedaccount) wrote :
summary: - ConfigDrive datasource fails when metadata files is null
+ [SRU] ConfigDrive datasource fails when metadata files is null
description: updated
Changed in cloud-init (Ubuntu Precise):
importance: Undecided → Medium
Revision history for this message
Chris J Arges (arges) 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 https://launchpad.net/ubuntu/+source/cloud-init/0.6.3-0ubuntu1.21 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: In Progress → Fix Committed
tags: added: verification-needed
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.21

---------------
cloud-init (0.6.3-0ubuntu1.21) precise; urgency=medium

  * debian/patches/lp-1492420-config-drive_skip-invalid-file-paths.patch:
     - skip null length paths defined on some Cloud Drive implementations
       (LP: #1492420).
  * debian/patches/lp-1492468-config-drive_alternative-interface-path.patch:
     - use alternative interface definition of "interfaces" when
       "network-interfaces" is invalid as used on some Cloud Drive
       implementations (LP: #1492468).

 -- Ben Howard <email address hidden> Tue, 08 Sep 2015 14:45:36 -0600

Changed in cloud-init (Ubuntu Precise):
status: Fix Committed → Fix Released
Revision history for this message
Chris J Arges (arges) wrote : Update Released

The verification of the Stable Release Update for cloud-init has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

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.