Can't retrieve OS::Heat::WaitCondition data by index

Bug #1434539 reported by Jordan Pittier
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Ishant Tyagi

Bug Description

Hi,

According to http://docs.openstack.org/hot-guide/content/user-data-boot-scripts-and-cloud-init.html I should be able to do

value: { get_attr: [wait_condition, data, '1'] }

But that doesn't seem to work on heat master.

Here's my stack to reproduce it:

heat_template_version: 2014-10-16

resources:

  wait_condition:
    type: OS::Heat::WaitCondition
    properties:
      handle: {get_resource: wait_handle}
      timeout: 60

  wait_handle:
    type: OS::Heat::WaitConditionHandle

  supervisor:
    type: OS::Nova::Server
    properties:
      image: "Ubuntu 14.04 amd64"
      flavor: m1.small
      key_name: jordan
      name: supervisor
      user_data_format: RAW
      user_data:
        str_replace:
          params:
            wc_notify_sup_ready: { get_attr: ['wait_handle', 'curl_cli'] }
          template: |
            #!/bin/bash
            set -x
            wc_notify_sup_ready --data-binary '{"status": "SUCCESS", "data": "foo"}'

outputs:
  nodes_ip:
    description: Data1
    value: { get_attr: ['wait_condition', 'data'] }
  nodes_ip2:
    description: Data2
    value: { get_attr: ['wait_condition', 'data', "1"] }
  nodes_ip3:
    description: Data3
    value: { get_attr: ['wait_condition', 'data', 1] }
  nodes_ip4:
    description: Data4
    value: { get_attr: ['wait_condition', data, "1"] }
  nodes_ip5:
    description: Data5
    value: { get_attr: ['wait_condition', data, 1] }
  nodes_ip6:
    description: Data6
    value: { get_attr: [wait_condition, data, 1] }
  nodes_ip7:
    description: Data7
    value: { get_attr: [wait_condition, data, "1"] }

Then take a look at the output of the stack.

I might be doing something wrong. I am not sure how to properly use WaitCondition but I am pretty sure there's a bug here.

Thanks !
Jordan

Revision history for this message
Jordan Pittier (jordan-pittier) wrote :
Download full text (5.2 KiB)

Output is

| outputs | [ |
| | { |
| | "output_value": "\"", |
| | "description": "Data6", |
| | "output_key": "nodes_ip6" |
| | }, |
| | { |
| | "output_value": null, |
| | "description": "Data7", |
| | "output_key": "nodes_ip7" |
| | }, |
| | { |
| | "output_value": null, |
| | "description": "Data4", |
| | "output_key": "nodes_ip4" |
| | }, |
| | { |
| | "output_value": "\"", |
| | "description": "Data5", |
| | "output_key": "nodes_ip5" |
| | }, |
| | { ...

Read more...

Revision history for this message
Thomas Herve (therve) wrote :

Not confirmed, but it seems logical looking at the code: WaitCondition get_attribute returns a json string, and we don't reload it later on.

Changed in heat:
importance: Undecided → Medium
milestone: none → kilo-rc1
Revision history for this message
Ishant Tyagi (ishanttyagi) wrote :

Yes WaitCondition _resolve_attributes returns json string and select_from_attribute is indexing on the string which is wrong . https://github.com/openstack/heat/blob/master/heat/engine/attributes.py#L198

Also { get_attr: [wait_condition, data, '1'] } is never possible because the 3rd parameter ( '1' ) should be a key and not a index. So the docs are also wrong here.

I am not sure what should be the output of waitcondition getattr , a json string or a map or a list of all the values of the keys.

Changed in heat:
assignee: nobody → Ishant Tyagi (ishant-tyagi)
Angus Salkeld (asalkeld)
Changed in heat:
status: New → Triaged
Revision history for this message
Kanagaraj Manickam (kanagaraj-manickam) wrote :
Angus Salkeld (asalkeld)
Changed in heat:
milestone: kilo-rc1 → next
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/182169

Changed in heat:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/182169
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=557d926d4071b82725d09d97bd9ab783484144a8
Submitter: Jenkins
Branch: master

commit 557d926d4071b82725d09d97bd9ab783484144a8
Author: tyagi <email address hidden>
Date: Mon May 11 08:11:08 2015 -0700

    Add attribute type for aws resources

    Add type field to the schema of the aws resources.

    Implements: blueprint add-type-in-attributes-schema
    closes-bug: #1434539
    Change-Id: I883313bf0f66c312cc592c62720dd828be488a5c

Changed in heat:
status: In Progress → Fix Committed
Changed in heat:
status: Fix Committed → Won't Fix
status: Won't Fix → 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.