Created
June 11, 2016 03:19
-
-
Save cwolferh/25661da92ad51e482f32374974e9b46a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using test_template_resource.py::TemplateResourceUpdateTest to show | |
how resource_properties_data are referenced from events by both | |
deleted and non-deleted stacks. See commentary at the end. | |
main_template = ''' | |
HeatTemplateFormatVersion: '2012-12-12' | |
Resources: | |
the_nested: | |
Type: the.yaml | |
Properties: | |
one: my_name | |
two: your_name | |
Outputs: | |
identifier: | |
Value: {Ref: the_nested} | |
value: | |
Value: {'Fn::GetAtt': [the_nested, the_str]} | |
''' | |
initial_tmpl = ''' | |
HeatTemplateFormatVersion: '2012-12-12' | |
Parameters: | |
one: | |
Default: foo | |
Type: String | |
two: | |
Default: bar | |
Type: String | |
Resources: | |
NestedResource: | |
Type: OS::Heat::RandomString | |
Properties: | |
salt: {Ref: one} | |
Outputs: | |
the_str: | |
Value: {'Fn::GetAtt': [NestedResource, value]} | |
''' | |
main_template_change_prop = ''' | |
HeatTemplateFormatVersion: '2012-12-12' | |
Resources: | |
the_nested: | |
Type: the.yaml | |
Properties: | |
one: updated_name | |
two: your_name | |
Outputs: | |
identifier: | |
Value: {Ref: the_nested} | |
value: | |
Value: {'Fn::GetAtt': [the_nested, the_str]} | |
''' | |
======================================================================= | |
# hackery: | |
# set enable_cleanup=False in stack_identifier = self.stack_create(....) | |
# and just enable: | |
:: scenario: main_template_change_prop | |
======================================================================= | |
bash-4.2$ openstack stack list --nested --deleted | |
+--------------------------------------+-------------------------------------------------------------+-----------------+---------------------+---------------------+--------------------------------------+ | |
| ID | Stack Name | Stack Status | Creation Time | Updated Time | Parent | | |
+--------------------------------------+-------------------------------------------------------------+-----------------+---------------------+---------------------+--------------------------------------+ | |
| f297697f-0338-485e-a7d7-cb17b95af771 | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg | UPDATE_COMPLETE | 2016-06-10T23:23:58 | 2016-06-10T23:24:04 | 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | | |
| 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | TemplateResourceUpdateTest-89345395 | UPDATE_COMPLETE | 2016-06-10T23:23:57 | 2016-06-10T23:24:03 | None | | |
+--------------------------------------+-------------------------------------------------------------+-----------------+---------------------+---------------------+--------------------------------------+ | |
openstack stack resource list -n 5 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | |
bash-4.2$ openstack stack resource list -n 5 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | |
+----------------+-----------------------------------------------------------------------------------------+------------------------+-----------------+---------------------+-------------------------------------------------------------+ | |
| resource_name | physical_resource_id | resource_type | resource_status | updated_time | stack_name | | |
+----------------+-----------------------------------------------------------------------------------------+------------------------+-----------------+---------------------+-------------------------------------------------------------+ | |
| the_nested | f297697f-0338-485e-a7d7-cb17b95af771 | the.yaml | UPDATE_COMPLETE | 2016-06-10T23:24:03 | TemplateResourceUpdateTest-89345395 | | |
| NestedResource | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg-NestedResource-heizt4sxrjs4 | OS::Heat::RandomString | CREATE_COMPLETE | 2016-06-10T23:24:04 | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg | | |
+----------------+-----------------------------------------------------------------------------------------+------------------------+-----------------+---------------------+-------------------------------------------------------------+ | |
openstack stack event list --nested-depth 5 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | |
2016-06-10 23:23:58 [TemplateResourceUpdateTest-89345395]: CREATE_IN_PROGRESS Stack CREATE started | |
2016-06-10 23:23:58 [the_nested]: CREATE_IN_PROGRESS state changed | |
2016-06-10 23:23:58 [TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg]: CREATE_IN_PROGRESS Stack CREATE started | |
2016-06-10 23:23:59 [the_nested]: CREATE_COMPLETE state changed | |
2016-06-10 23:23:59 [NestedResource]: CREATE_IN_PROGRESS state changed | |
2016-06-10 23:23:59 [NestedResource]: CREATE_COMPLETE state changed | |
2016-06-10 23:23:59 [TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg]: CREATE_COMPLETE Stack CREATE completed successfully | |
2016-06-10 23:24:00 [TemplateResourceUpdateTest-89345395]: CREATE_COMPLETE Stack CREATE completed successfully | |
2016-06-10 23:24:03 [TemplateResourceUpdateTest-89345395]: UPDATE_IN_PROGRESS Stack UPDATE started | |
2016-06-10 23:24:03 [the_nested]: UPDATE_IN_PROGRESS state changed | |
2016-06-10 23:24:04 [TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg]: UPDATE_IN_PROGRESS Stack UPDATE started | |
2016-06-10 23:24:04 [NestedResource]: UPDATE_IN_PROGRESS state changed | |
2016-06-10 23:24:04 [NestedResource]: UPDATE_COMPLETE The Resource NestedResource requires replacement. | |
2016-06-10 23:24:04 [NestedResource]: CREATE_IN_PROGRESS state changed | |
2016-06-10 23:24:05 [NestedResource]: CREATE_COMPLETE state changed | |
2016-06-10 23:24:07 [TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg]: UPDATE_COMPLETE Stack UPDATE completed successfully | |
2016-06-10 23:24:08 [the_nested]: UPDATE_COMPLETE state changed | |
2016-06-10 23:24:09 [TemplateResourceUpdateTest-89345395]: UPDATE_COMPLETE Stack UPDATE completed successfully | |
select * from resource_properties_data; | |
+----+---------------------------------------------+-----------+---------------------+------------+ | |
| id | data | encrypted | created_at | updated_at | | |
+----+---------------------------------------------+-----------+---------------------+------------+ | |
| 70 | {"two": "your_name", "one": "my_name"} | 0 | 2016-06-10 23:23:58 | NULL | | |
| 71 | {"salt": "my_name"} | 0 | 2016-06-10 23:23:59 | NULL | | |
| 72 | {"two": "your_name", "one": "my_name"} | 0 | 2016-06-10 23:24:03 | NULL | | |
| 73 | {"salt": "my_name"} | 0 | 2016-06-10 23:24:04 | NULL | | |
| 74 | {"salt": "updated_name"} | 0 | 2016-06-10 23:24:04 | NULL | | |
| 75 | {"two": "your_name", "one": "updated_name"} | 0 | 2016-06-10 23:24:08 | NULL | | |
+----+---------------------------------------------+-----------+---------------------+------------+ | |
select id, name, rsrc_prop_data_id from resource; | |
+----+----------------+-------------------+ | |
| id | name | rsrc_prop_data_id | | |
+----+----------------+-------------------+ | |
| 28 | the_nested | 75 | | |
| 30 | NestedResource | 74 | | |
+----+----------------+-------------------+ | |
select id, stack_id, physical_resource_id, rsrc_prop_data_id, resource_action, resource_status from event where rsrc_prop_data_id is not NULL order by id; | |
+-----+--------------------------------------+-----------------------------------------------------------------------------------------+-------------------+-----------------+-----------------+ | |
| id | stack_id | physical_resource_id | rsrc_prop_data_id | resource_action | resource_status | | |
+-----+--------------------------------------+-----------------------------------------------------------------------------------------+-------------------+-----------------+-----------------+ | |
| 318 | 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | NULL | 70 | CREATE | IN_PROGRESS | | |
| 320 | f297697f-0338-485e-a7d7-cb17b95af771 | NULL | 71 | CREATE | IN_PROGRESS | | |
| 321 | f297697f-0338-485e-a7d7-cb17b95af771 | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg-NestedResource-jgarzpf2ahan | 71 | CREATE | COMPLETE | | |
| 323 | 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | f297697f-0338-485e-a7d7-cb17b95af771 | 70 | CREATE | COMPLETE | | |
| 326 | 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | f297697f-0338-485e-a7d7-cb17b95af771 | 72 | UPDATE | IN_PROGRESS | | |
| 328 | f297697f-0338-485e-a7d7-cb17b95af771 | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg-NestedResource-jgarzpf2ahan | 73 | UPDATE | IN_PROGRESS | | |
| 329 | f297697f-0338-485e-a7d7-cb17b95af771 | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg-NestedResource-jgarzpf2ahan | 73 | UPDATE | COMPLETE | | |
| 330 | f297697f-0338-485e-a7d7-cb17b95af771 | NULL | 74 | CREATE | IN_PROGRESS | | |
| 331 | f297697f-0338-485e-a7d7-cb17b95af771 | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg-NestedResource-heizt4sxrjs4 | 74 | CREATE | COMPLETE | | |
| 332 | 690f99bd-d6c9-4f99-a136-08f7bf33d86c | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg-NestedResource-jgarzpf2ahan | 73 | DELETE | IN_PROGRESS | | |
| 333 | 690f99bd-d6c9-4f99-a136-08f7bf33d86c | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg-NestedResource-jgarzpf2ahan | 73 | DELETE | COMPLETE | | |
| 337 | 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | f297697f-0338-485e-a7d7-cb17b95af771 | 75 | UPDATE | COMPLETE | | |
+-----+--------------------------------------+-----------------------------------------------------------------------------------------+-------------------+-----------------+-----------------+ | |
select id, name, deleted_at, backup from stack; | |
+--------------------------------------+--------------------------------------------------------------+---------------------+--------+ | |
| id | name | deleted_at | backup | | |
+--------------------------------------+--------------------------------------------------------------+---------------------+--------+ | |
| 5c9c0f45-1bba-4e01-a2c0-263207b77e26 | TemplateResourceUpdateTest-89345395* | 2016-06-10 23:24:09 | 1 | | |
| 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | TemplateResourceUpdateTest-89345395 | NULL | 0 | | |
| 690f99bd-d6c9-4f99-a136-08f7bf33d86c | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg* | 2016-06-10 23:24:07 | 1 | | |
| f297697f-0338-485e-a7d7-cb17b95af771 | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg | NULL | 0 | | |
+--------------------------------------+--------------------------------------------------------------+---------------------+--------+ | |
> Aside: is this a bug that we can't see deleted stacks? | |
> bash-4.2$ openstack stack list --hidden --deleted --nested | |
> +--------------------------------------+-------------------------------------------------------------+-----------------+---------------------+---------------------+--------------------------------------+ | |
> | ID | Stack Name | Stack Status | Creation Time | Updated Time | Parent | | |
> +--------------------------------------+-------------------------------------------------------------+-----------------+---------------------+---------------------+--------------------------------------+ | |
> | f297697f-0338-485e-a7d7-cb17b95af771 | TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg | UPDATE_COMPLETE | 2016-06-10T23:23:58 | 2016-06-10T23:24:04 | 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | | |
> | 60d245ec-e493-4f1b-8b14-0b81de6bf0ac | TemplateResourceUpdateTest-89345395 | UPDATE_COMPLETE | 2016-06-10T23:23:57 | 2016-06-10T23:24:03 | None | | |
> +--------------------------------------+-------------------------------------------------------------+-----------------+---------------------+---------------------+--------------------------------------+ | |
Commentary: resource_properties_data of [ 73 | {"salt": "my_name"} ] | |
is associated with the resource NestedResource. The original | |
NestedResource got replaced as part of the stack update. However, as | |
part of that update, an event is recorded (329) where the old resource | |
(TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg-NestedResource-jgarzpf2ahan) | |
is recorded with the new stack | |
(TemplateResourceUpdateTest-89345395-the_nested-ujtrctu73shg-NestedResource-jgarzpf2ahan) | |
with resource_properties_data=73. Thus, when we purge the deleted | |
stacks, we cannot delete resource_properties_data=73 since we still | |
have an event with a non-deleted stack that references it. | |
================================================================================================== | |
:: scenario: no_changes | |
-- No problem! | |
================================================================================================== | |
bash-4.2$ openstack stack list --nested | |
+--------------------------------------+---------------------------------------------------------------+-----------------+---------------------+---------------------+--------------------------------------+ | |
| ID | Stack Name | Stack Status | Creation Time | Updated Time | Parent | | |
+--------------------------------------+---------------------------------------------------------------+-----------------+---------------------+---------------------+--------------------------------------+ | |
| e2095fee-96ff-4b74-8e53-8ced2165a288 | TemplateResourceUpdateTest-1166678608-the_nested-6dg2b4kzdllc | UPDATE_COMPLETE | 2016-06-10T21:43:45 | 2016-06-10T21:43:50 | 9ee2135d-9203-4f4f-9a26-83ea0e1ff3fc | | |
| 9ee2135d-9203-4f4f-9a26-83ea0e1ff3fc | TemplateResourceUpdateTest-1166678608 | UPDATE_COMPLETE | 2016-06-10T21:43:44 | 2016-06-10T21:43:50 | None | | |
+--------------------------------------+---------------------------------------------------------------+-----------------+---------------------+---------------------+--------------------------------------+ | |
bash-4.2$ openstack stack resource list -n 5 9ee2135d-9203-4f4f-9a26-83ea0e1ff3fc | |
+----------------+-------------------------------------------------------------------------------------------+------------------------+-----------------+---------------------+---------------------------------------------------------------+ | |
| resource_name | physical_resource_id | resource_type | resource_status | updated_time | stack_name | | |
+----------------+-------------------------------------------------------------------------------------------+------------------------+-----------------+---------------------+---------------------------------------------------------------+ | |
| the_nested | e2095fee-96ff-4b74-8e53-8ced2165a288 | the.yaml | UPDATE_COMPLETE | 2016-06-10T21:43:50 | TemplateResourceUpdateTest-1166678608 | | |
| NestedResource | TemplateResourceUpdateTest-1166678608-the_nested-6dg2b4kzdllc-NestedResource-gpykydgvwx3m | OS::Heat::RandomString | CREATE_COMPLETE | 2016-06-10T21:43:45 | TemplateResourceUpdateTest-1166678608-the_nested-6dg2b4kzdllc | | |
+----------------+-------------------------------------------------------------------------------------------+------------------------+-----------------+---------------------+---------------------------------------------------------------+ | |
bash-4.2$ openstack stack event list --nested-depth 5 9ee2135d-9203-4f4f-9a26-83ea0e1ff3fc | |
2016-06-10 21:43:44 [TemplateResourceUpdateTest-1166678608]: CREATE_IN_PROGRESS Stack CREATE started | |
2016-06-10 21:43:44 [the_nested]: CREATE_IN_PROGRESS state changed | |
2016-06-10 21:43:45 [TemplateResourceUpdateTest-1166678608-the_nested-6dg2b4kzdllc]: CREATE_IN_PROGRESS Stack CREATE started | |
2016-06-10 21:43:45 [NestedResource]: CREATE_IN_PROGRESS state changed | |
2016-06-10 21:43:45 [NestedResource]: CREATE_COMPLETE state changed | |
2016-06-10 21:43:45 [TemplateResourceUpdateTest-1166678608-the_nested-6dg2b4kzdllc]: CREATE_COMPLETE Stack CREATE completed successfully | |
2016-06-10 21:43:46 [the_nested]: CREATE_COMPLETE state changed | |
2016-06-10 21:43:46 [TemplateResourceUpdateTest-1166678608]: CREATE_COMPLETE Stack CREATE completed successfully | |
2016-06-10 21:43:50 [TemplateResourceUpdateTest-1166678608]: UPDATE_IN_PROGRESS Stack UPDATE started | |
2016-06-10 21:43:50 [the_nested]: UPDATE_IN_PROGRESS state changed | |
2016-06-10 21:43:50 [TemplateResourceUpdateTest-1166678608-the_nested-6dg2b4kzdllc]: UPDATE_IN_PROGRESS Stack UPDATE started | |
2016-06-10 21:43:52 [the_nested]: UPDATE_COMPLETE state changed | |
2016-06-10 21:43:52 [TemplateResourceUpdateTest-1166678608-the_nested-6dg2b4kzdllc]: UPDATE_COMPLETE Stack UPDATE completed successfully | |
2016-06-10 21:43:53 [TemplateResourceUpdateTest-1166678608]: UPDATE_COMPLETE Stack UPDATE completed successfully | |
select * from resource_properties_data; | |
+----+----------------------------------------+-----------+---------------------+------------+ | |
| id | data | encrypted | created_at | updated_at | | |
+----+----------------------------------------+-----------+---------------------+------------+ | |
| 52 | {"two": "your_name", "one": "my_name"} | 0 | 2016-06-10 21:43:44 | NULL | | |
| 53 | {"salt": "my_name"} | 0 | 2016-06-10 21:43:45 | NULL | | |
| 54 | {"two": "your_name", "one": "my_name"} | 0 | 2016-06-10 21:43:50 | NULL | | |
+----+----------------------------------------+-----------+---------------------+------------+ | |
select id, name, rsrc_prop_data_id from resource; | |
+----+----------------+-------------------+ | |
| id | name | rsrc_prop_data_id | | |
+----+----------------+-------------------+ | |
| 21 | the_nested | 54 | | |
| 22 | NestedResource | 53 | | |
+----+----------------+-------------------+ | |
select id, stack_id, physical_resource_id, rsrc_prop_data_id, resource_action, resource_status from event where rsrc_prop_data_id is not NULL order by id; | |
+-----+--------------------------------------+-------------------------------------------------------------------------------------------+-------------------+-----------------+-----------------+ | |
| id | stack_id | physical_resource_id | rsrc_prop_data_id | resource_action | resource_status | | |
+-----+--------------------------------------+-------------------------------------------------------------------------------------------+-------------------+-----------------+-----------------+ | |
| 234 | 9ee2135d-9203-4f4f-9a26-83ea0e1ff3fc | NULL | 52 | CREATE | IN_PROGRESS | | |
| 236 | e2095fee-96ff-4b74-8e53-8ced2165a288 | NULL | 53 | CREATE | IN_PROGRESS | | |
| 237 | e2095fee-96ff-4b74-8e53-8ced2165a288 | TemplateResourceUpdateTest-1166678608-the_nested-6dg2b4kzdllc-NestedResource-gpykydgvwx3m | 53 | CREATE | COMPLETE | | |
| 239 | 9ee2135d-9203-4f4f-9a26-83ea0e1ff3fc | e2095fee-96ff-4b74-8e53-8ced2165a288 | 52 | CREATE | COMPLETE | | |
| 242 | 9ee2135d-9203-4f4f-9a26-83ea0e1ff3fc | e2095fee-96ff-4b74-8e53-8ced2165a288 | 54 | UPDATE | IN_PROGRESS | | |
| 247 | 9ee2135d-9203-4f4f-9a26-83ea0e1ff3fc | e2095fee-96ff-4b74-8e53-8ced2165a288 | 54 | UPDATE | COMPLETE | | |
+-----+--------------------------------------+-------------------------------------------------------------------------------------------+-------------------+-----------------+-----------------+ | |
======================================================================= | |
======================================================================= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment