fail to get nested output from OS::Heat::ResourceGroup resources

Bug #1719603 reported by Nikita Gerasimov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Rabi Mishra
Pike
Fix Committed
Medium
Rabi Mishra
Queens
Fix Released
Medium
Rabi Mishra

Bug Description

heat version: 9.0.0

template:

heat_template_version: 2017-02-24
description: test template
parameters:
  image_name:
    type: string
    constraints:
      - custom_constraint: glance.image
  flavor_name:
    type: string
    constraints:
      - custom_constraint: nova.flavor
resources:
  test_net:
    type: OS::Neutron::Net
  test_subnet:
    type: OS::Neutron::Subnet
    properties:
      network: { get_resource: test_net }
      ip_version: 4
      cidr: "192.168.1.0/24"
      gateway_ip: null
  test_server:
    type: OS::Heat::ResourceGroup
    properties:
      count: 1
      resource_def:
        type: OS::Nova::Server
        properties:
          user_data_format: RAW
          image: { get_param: image_name }
          flavor: { get_param: flavor_name }
          networks:
            - network: { get_resource: test_net }
outputs:
  test:
    value:
      get_attr:
        - test_server
        - addresses
        - get_resource: test_net
        - 0
        - addr

try to create stack and get:
ERROR: TypeError: : resources.test_server: : sequence item 1: expected string or Unicode, NoneType found

on heat 8.0.4 template works fine and outputs return array of addr

heat engine log:
2017-09-26 12:53:04.201 3732 DEBUG heat.engine.parameter_groups [req-a9a19cf8-69e6-44bf-9f1d-c1691da5412e - o3ltest - default default] Validating Parameter Groups: OS::project_id, image_name, OS::stack_id, flavor_name validate /usr/lib/python2.7/site-packages/heat/engine/parameter_groups.py:42
2017-09-26 12:53:04.203 3732 INFO heat.engine.resource [req-a9a19cf8-69e6-44bf-9f1d-c1691da5412e - o3ltest - default default] Validating Net "test_net"
2017-09-26 12:53:04.204 3732 INFO heat.engine.resource [req-a9a19cf8-69e6-44bf-9f1d-c1691da5412e - o3ltest - default default] Validating ResourceGroup "test_server"
2017-09-26 12:53:04.205 3732 INFO heat.engine.stack [req-a9a19cf8-69e6-44bf-9f1d-c1691da5412e - o3ltest - default default] Exception in stack validation
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack Traceback (most recent call last):
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack File "/usr/lib/python2.7/site-packages/heat/engine/stack.py", line 879, in validate
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack result = res.validate()
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack File "/usr/lib/python2.7/site-packages/heat/engine/resources/stack_resource.py", line 65, in validate
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack self.validate_nested_stack()
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack File "/usr/lib/python2.7/site-packages/heat/engine/resources/openstack/heat/resource_group.py", line 285, in validate_nested_stack
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack include_all=True)
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack File "/usr/lib/python2.7/site-packages/heat/engine/resources/openstack/heat/resource_group.py", line 567, in _assemble_nested
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack get_attr):
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack File "/usr/lib/python2.7/site-packages/heat/engine/resources/openstack/heat/resource_group.py", line 465, in _nested_output_defns
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack output_name = ', '.join(attr)
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack TypeError: sequence item 1: expected string or Unicode, NoneType found
2017-09-26 12:53:04.205 3732 ERROR heat.engine.stack

Revision history for this message
Rabi Mishra (rabi) wrote :

I think this is bug most probably introduced by I61d8e5deff45a648657ba685e033a00a492412f2. For nested stack validation we may not need to check for referenced_attrs (as resolving them may give us None).

Changed in heat:
importance: Undecided → Medium
assignee: nobody → Rabi Mishra (rabi)
Rabi Mishra (rabi)
Changed in heat:
milestone: none → queens-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/535207

Changed in heat:
status: New → In Progress
Revision history for this message
Zane Bitter (zaneb) wrote :

For future readers, the issue here is in determining which attributes of the resource group we need to store in order to be able to supply this output:

    value:
      get_attr:
        - test_server
        - addresses
        - get_resource: test_net
        - 0
        - addr

During validation {get_resource: test_net} returns None, and we weren't handling generation of the template adequately when one of the values in the attribute path was not a string.

In addition to ResourceGroup, the following resources are also affected:

- OS::Heat::SoftwareDeploymentGroup
- OS::Heat::ResourceChain
- OS::Heat::AutoScalingGroup

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

Reviewed: https://review.openstack.org/535207
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=aabb3392b30e4905e8b780bec4c819ec6058b2b6
Submitter: Zuul
Branch: master

commit aabb3392b30e4905e8b780bec4c819ec6058b2b6
Author: rabi <email address hidden>
Date: Thu Jan 18 12:53:57 2018 +0530

    Fix nested template genearation when attribute path is not string

    When determining attributes to cache, we seem to be assuming the
    paths to be strings. If there are resource references in outputs
    it would be None during validation.

    As we've the same code snippet in all group resources
    ex. ResourceGroup, ResourceChain and heat AutoScalingGroup, this
    fixes it in all those places.

    Change-Id: I36d623b183d01632041113f7bff63bf255f5d53c
    Closes-Bug: #1719603

Changed in heat:
status: In Progress → Fix Released
Zane Bitter (zaneb)
tags: added: pike-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.openstack.org/536007

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

Reviewed: https://review.openstack.org/536007
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=27426e83306e55067e1a450ed0cce37533749a8c
Submitter: Zuul
Branch: stable/pike

commit 27426e83306e55067e1a450ed0cce37533749a8c
Author: rabi <email address hidden>
Date: Thu Jan 18 12:53:57 2018 +0530

    Fix nested template genearation when attribute path is not string

    When determining attributes to cache, we seem to be assuming the
    paths to be strings. If there are resource references in outputs
    it would be None during validation.

    As we've the same code snippet in all group resources
    ex. ResourceGroup, ResourceChain and heat AutoScalingGroup, this
    fixes it in all those places.

    Change-Id: I36d623b183d01632041113f7bff63bf255f5d53c
    Closes-Bug: #1719603
    (cherry picked from commit aabb3392b30e4905e8b780bec4c819ec6058b2b6)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/heat 10.0.0.0b3

This issue was fixed in the openstack/heat 10.0.0.0b3 development milestone.

Zane Bitter (zaneb)
tags: removed: pike-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/heat 9.0.3

This issue was fixed in the openstack/heat 9.0.3 release.

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.