Problems with OS::Nova::Server metadata property and complex values

Bug #1274155 reported by Lars Kellogg-Stedman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Lars Kellogg-Stedman

Bug Description

It is possible to set the "metadata" property of an OS::Nova::Server instance to a complex value. For example:

instance0:
  type: OS::Nova::Server
  metadata:
    internal_ip: {get_attr: [instance0_eth1, fixed_ips]}

While this does not result in any errors, the value available in the "meta" key of the metadata service (http://169.254.169.254/openstack/latest/meta_data.json) is the result of a Python "str()" on the value:

  $ curl http://169.254.169.254/openstack/latest/meta_data.json | jq .meta
  {
    "internal_ip": "[{u'subnet_id': u'20bb4a78-876a-465a-bfe8-868e800e3c0c', u'ip_address': u'10.0.0.2'}]",
  }

It seems like heat should do one of two things:

(a) Refuse to create the stack if a metadata key is set to a non-string value, or
(b) Serialize complex values using, e.g., JSON

Revision history for this message
Steve Baker (steve-stevebaker) wrote :

I assume you mean the metadata property:

instance0:
  type: OS::Nova::Server
  properties:
    metadata:
      internal_ip: {get_attr: [instance0_eth1, fixed_ips]}

Serialising complex values to json seems reasonable. Feel free to provide a fix which implements and documents this.

Changed in heat:
status: New → Triaged
importance: Undecided → Medium
milestone: none → icehouse-3
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/70045

Changed in heat:
assignee: nobody → Lars Kellogg-Stedman (larsks)
status: Triaged → In Progress
Revision history for this message
Lars Kellogg-Stedman (larsks) wrote :

The referenced change serializes all non-string values to JSON when they are passed to nova. I have updated test_server_update_nova_metadata (and _with_delete) to check this, but I did not otherwise see a good location for documentation in this repository. If this patch or similar is accepted, it seems as if the rigth place for documentation would be http://docs.openstack.org/developer/heat/template_guide/openstack.html#OS::Nova::Server (and I'm happy to take care of submitting a patch for that if necessary).

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

Reviewed: https://review.openstack.org/70045
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=3e3fc3e1ff0ce4edce9f432fe31d2d8e45082681
Submitter: Jenkins
Branch: master

commit 3e3fc3e1ff0ce4edce9f432fe31d2d8e45082681
Author: Lars Kellogg-Stedman <email address hidden>
Date: Wed Jan 29 22:05:47 2014 -0500

    serialize non-string nova metadata

    This patches ensures that non-string metadata values passed to Nova
    are JSON-encoded. This permits setting metadata to complex values,
    such as:

        instance0:
          type: OS::Nova::Server
          properties:
            metadata:
              internal_ip: {get_attr: [instance0_eth1, fixed_ips]}

    Change-Id: I1a943876d805dce731771b18a39d0c78f617264a
    Closes-Bug: 1274155

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