get_param is not working with stack-update
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Heat |
Fix Released
|
High
|
Zane Bitter |
Bug Description
While fixing https:/
when updating the stack with template that uses get_param for a resource parameter to be updated, I can not reference the parameters of the old resource inside the handle_update method, as self.properties at this stage already holds new values.
On the contrary, when not using get_param and putting updated values directly in the resources section of the template, self.properties of the resource still holds values for old stack during handle_update, allowing usage of the old parameters while updating the resource.
Unfortunately, there are only few resources in Heat now that use old parameter values during update, so I can not (yet) provide the example with existing resources, so I give here the templates I was using while making VolumeAttachment updatable (the code in the gerrit review given above).
I have two volumes in cinder
$>cinder list
+------
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+------
| e0383cb9-
| e90d0e9f-
+------
vol1.yaml
=======
heat_template_
description: >
HOT template that creates one instance and attaches a cinder volume to it.
resources:
nova_instance:
type: OS::Nova::Server
properties:
availabil
image: cirros-
flavor: m1.nano
volume_
type: OS::Cinder:
properties:
instance_
volume_id: e90d0e9f-
mountpoint: '/dev/vdc'
outputs:
instance_ip:
description: The IP address of the deployed instance
value: { get_attr: [nova_instance, first_address] }
vol2.yaml
=======
heat_template_
description: >
HOT template that creates one instance and attaches a cinder volume to it.
resources:
nova_instance:
type: OS::Nova::Server
properties:
availabil
image: cirros-
flavor: m1.nano
volume_
type: OS::Cinder:
properties:
instance_
volume_id: e0383cb9-
mountpoint: '/dev/vdc'
outputs:
instance_ip:
description: The IP address of the deployed instance
value: { get_attr: [nova_instance, first_address] }
vols.yaml
=======
heat_template_
description: >
HOT template that creates one instance and attaches a cinder volume to it.
parameters:
volume:
type: string
description: ID of the volume to attach
resources:
nova_instance:
type: OS::Nova::Server
properties:
availabil
image: cirros-
flavor: m1.nano
volume_
type: OS::Cinder:
properties:
instance_
volume_id: { get_param: volume }
mountpoint: '/dev/vdc'
outputs:
instance_ip:
description: The IP address of the deployed instance
value: { get_attr: [nova_instance, first_address] }
When using templates without get_param:
$> heat stack-create -f vol1.yaml test
$> cinder list
+------
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+------
| e0383cb9-
| e90d0e9f-
+------
$> heat stack-update -f vol2.yaml test
$> cinder list
+------
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+------
| e0383cb9-
| e90d0e9f-
+------
volume attachment is successfully updated.
When using template with get_param:
$> heat stack-create -f vols.yaml -P volume=
$> cinder list
+------
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+------
| e0383cb9-
| e90d0e9f-
+------
$> heat stack-update -f vols.yaml -P volume=
the update fails.
Below are what I consider relevant lines from heat-engine log):
2014-03-12 14:13:29.449 INFO heat.engine.
2014-03-12 14:13:29.525 DEBUG heat.engine.
-----
2014-03-12 14:13:29.845 WARNING heat.engine.
-----
2014-03-12 14:13:31.149 TRACE heat.engine.
Notice that heat immediately tries to detach the new volume instead of the old one, which is naturally not attached, and proceeds with attaching it again while the old volume is still attached to the same mount, which fails.
I checked it with pdb, and it seems that the problem is what I already described - different values in self.properties while executing handle_update.
I will try to come up with example that uses some code that is already in master branch.
Changed in heat: | |
status: | Invalid → New |
assignee: | nobody → Zane Bitter (zaneb) |
importance: | Undecided → High |
Changed in heat: | |
status: | New → Triaged |
milestone: | none → icehouse-rc1 |
Changed in heat: | |
status: | Triaged → In Progress |
Changed in heat: | |
status: | Fix Committed → Fix Released |
Changed in heat: | |
milestone: | icehouse-rc1 → 2014.1 |
Going though the code I have found only one resource that seems to use old properties values in the fashion vulnerable to the above behavior, and that is OS::Neutron::Pool. But while digging through it's handle_update several more bugs were found, so I am waiting for them to be fixed in order to prove my point with this bug.