Can't import ResourceGroup index to list index in get_param

Bug #1566321 reported by Steven Hardy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Rico Lin

Bug Description

When creating a RandomString resource, we assume all values in the properties are available during validate(), but this is not true when you reference certain properties e.g length via get_param inside a nested stack:

https://review.openstack.org/#/c/301623/2

This shows the problem, which fails with:

ERROR: Failed to validate: Failed to validate: resources[0]: Value '' is not an integer

ERROR heat.engine.stack [req-21a6c303-1282-4dc2-afe5-19e3e9ea5973 None admin] Exception: Value '' is not an integer
2016-04-05 14:40:36.316 TRACE heat.engine.stack Traceback (most recent call last):
2016-04-05 14:40:36.316 TRACE heat.engine.stack File "/opt/stack/heat/heat/engine/stack.py", line 753, in validate
2016-04-05 14:40:36.316 TRACE heat.engine.stack result = res.validate()
2016-04-05 14:40:36.316 TRACE heat.engine.stack File "/opt/stack/heat/heat/engine/resources/openstack/heat/random_string.py", line 273, in validate
2016-04-05 14:40:36.316 TRACE heat.engine.stack length = self.properties[self.LENGTH]
2016-04-05 14:40:36.316 TRACE heat.engine.stack File "/opt/stack/heat/heat/engine/properties.py", line 453, in __getitem__
2016-04-05 14:40:36.316 TRACE heat.engine.stack return self._get_property_value(key)
2016-04-05 14:40:36.316 TRACE heat.engine.stack File "/opt/stack/heat/heat/engine/properties.py", line 446, in _get_property_value
2016-04-05 14:40:36.316 TRACE heat.engine.stack return self.get_user_value(key, validate)
2016-04-05 14:40:36.316 TRACE heat.engine.stack File "/opt/stack/heat/heat/engine/properties.py", line 438, in get_user_value
2016-04-05 14:40:36.316 TRACE heat.engine.stack raise ValueError(six.text_type(e))
2016-04-05 14:40:36.316 TRACE heat.engine.stack ValueError: Value '' is not an integer
2016-04-05 14:40:36.316 TRACE heat.engine.stack

The problem AFAICT is that random_string.py shouldn't fail in validate(), because the check for self.properties[self.LENGTH] may fail to get a value to validate until create.

Rico Lin (rico-lin)
Changed in heat:
assignee: nobody → Rico Lin (rico-lin)
milestone: none → newton-1
status: New → Triaged
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/302042

Changed in heat:
status: Triaged → In Progress
Revision history for this message
Rico Lin (rico-lin) wrote : Re: RandomString validation happens to early

This bug is discovered by [1].
After some trace, I found out that we surprisely didn't support length: {get_param: [lengths, '1']}
this can lead to length: {get_param: [lengths, {get_param: index}]} in [1] raise error and didn't know what to do in this RG case.
This means that we now have a way to import "%index%" to a list index in get_param

[1]https://review.openstack.org/#/c/301623/2

summary: - RandomString validation happens to early
+ Can't import ResourceGroup index to list index in get_param
Revision history for this message
Rico Lin (rico-lin) wrote :

Steven
I change the title from `RandomString validation happens to early` to `Can't import ResourceGroup index to list index in get_param`.
Since IMO we can have better understanding of this bug. Feel free to change back if it's not appropriated.

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

Reviewed: https://review.openstack.org/302042
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=1df6d2aa7984035015391abe13f86b8980035b92
Submitter: Jenkins
Branch: master

commit 1df6d2aa7984035015391abe13f86b8980035b92
Author: ricolin <email address hidden>
Date: Wed Apr 6 14:00:44 2016 +0800

    Support string index for list in get_param

    Accept for string index like '1' for list in get_param function
    For example, with lengths equal to [4,5,6]. We can write down something
    like this: `length: {get_param: [lengths,'1']}`.
    Closes-Bug: #1566321

    Change-Id: I52447dea93ff2e6a32d597a632093661feed7c71

Changed in heat:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (stable/mitaka)

Fix proposed to branch: stable/mitaka
Review: https://review.openstack.org/302956

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

Fix proposed to branch: stable/liberty
Review: https://review.openstack.org/302963

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

Reviewed: https://review.openstack.org/302956
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=f71f912a95860bd7a0efba2ea2c7b383bddca0bd
Submitter: Jenkins
Branch: stable/mitaka

commit f71f912a95860bd7a0efba2ea2c7b383bddca0bd
Author: ricolin <email address hidden>
Date: Wed Apr 6 14:00:44 2016 +0800

    Support string index for list in get_param

    Accept for string index like '1' for list in get_param function
    For example, with lengths equal to [4,5,6]. We can write down something
    like this: `length: {get_param: [lengths,'1']}`.
    Closes-Bug: #1566321
    Depends-On: I14377e0497f1589f1234226babcf7d78761b7b7b

    Change-Id: I52447dea93ff2e6a32d597a632093661feed7c71

tags: added: in-stable-mitaka
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/heat 7.0.0.0b1

This issue was fixed in the openstack/heat 7.0.0.0b1 development milestone.

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

Reviewed: https://review.openstack.org/302963
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=e13e00734d2d563b18ed7428527f1c67f5b8e686
Submitter: Jenkins
Branch: stable/liberty

commit e13e00734d2d563b18ed7428527f1c67f5b8e686
Author: ricolin <email address hidden>
Date: Wed Apr 6 14:00:44 2016 +0800

    Support string index for list in get_param

    Accept for string index like '1' for list in get_param function
    For example, with lengths equal to [4,5,6]. We can write down something
    like this: `length: {get_param: [lengths,'1']}`.
    Closes-Bug: #1566321

    Change-Id: I52447dea93ff2e6a32d597a632093661feed7c71

tags: added: in-stable-liberty
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/heat 6.1.0

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

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

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

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

This issue was fixed in the openstack/heat 6.1.0 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.