loguserdata.py does not work with cloud-init >= 0.7.0

Bug #1103793 reported by Clint Byrum
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Clint Byrum

Bug Description

In versions of cloud-init prior to 0.6.x, cfn-userdata would be executed by cloud-init

In 0.6.x, loguserdata.py has to chmod +x cfn-userdata and run it, and log the output.

In doing so, it tries to find out the data path from cloudinit and assumes if cloudinit.get_cpath('data') raises an AttributeError that this is an older version and it has already been executed.

In fact with 0.7.x the call has been removed and the code to get the same data is quite a bit more complex.

So, it seems that things have been intertwined that should not.

* We need to detect if an old version of cloud-init already ran cfn-userdata
* We need to write files to disk in a predictable location.

The solution is to detect the version of cloudinit. 0.6.x did not have cloudinit.version, so this code should do the trick:

from distutils import version as vr
import cloudinit

if hasattr(cloudinit, 'get_cpath'):
    ci_version = vr.StrictVersion('0.6.0')
else:
    try:
        import cloudinit.version
    except ImportError:
        ci_version = vr.StrictVersion('0.5.0')
    else:
        ci_version = cloudinit.version.version()

if ci_version < vr.StrictVersion('0.6.0'):
    log_message()
    sys.exit(0)

Revision history for this message
Clint Byrum (clint-fewbar) wrote :

Oh also we should just assume /var/lib/cloud/data ... everything else in heat does. Actually longer term, we should move all of that to /var/lib/heat/data

Angus Salkeld (asalkeld)
Changed in heat:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/20375

Changed in heat:
assignee: nobody → Clint Byrum (clint-fewbar)
status: New → In Progress
Revision history for this message
Clint Byrum (clint-fewbar) wrote :

I've tested the proposed fix (using pkg_resources) on Ubuntu 12.10, 12.04, and 10.04. Works fine there. In theory it will work fine on RHEL6/CentOS6 and Fedora16 too, as they have pkg_resources by default.

Also, the only system in active use that I could find with cloud-init older than 0.6 is Ubuntu 10.04. Since it will always have pkg_resources (it is included in the server seed used to build cloud images and server isos), I think its safe to make this assumption. At worst, we'll get a backtrace showing the failed import of pkg_resources in cloud-init's output.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/20375
Committed: http://github.com/openstack/heat/commit/8d6aa11e707dee66c421bc2906c166fc58c150dc
Submitter: Jenkins
Branch: master

commit 8d6aa11e707dee66c421bc2906c166fc58c150dc
Author: Clint Byrum <email address hidden>
Date: Wed Jan 23 21:59:58 2013 -0800

    Use pkg_resources to detect version of cloud-init

    Previously the present of an API call only present in cloud-init 0.6.x
    was used to determine whether or not cfn-userdata would have been executed
    or not. The API call was removed in 0.7.x. This Fixes bug #1103793

    Change-Id: I27129f8ae6144ae7172b7159ed70fc5f0d7d07b9

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
milestone: none → grizzly-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: grizzly-3 → 2013.1
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.