Bug 1264234

Summary: heat updates raw_template when there is no change in raw_template
Product: Red Hat OpenStack Reporter: Steve Baker <sbaker>
Component: openstack-heatAssignee: Steve Baker <sbaker>
Status: CLOSED ERRATA QA Contact: Amit Ugol <augol>
Severity: high Docs Contact:
Priority: urgent    
Version: 7.0 (Kilo)CC: arkady_kanevsky, augol, calfonso, ccoursey, cdevine, christopher_dearborn, dmaley, John_walsh, jraju, jschluet, kurt_hey, mburns, morazi, ohochman, pablo.iranzo, pbandark, rajini.karthik, randy_perryman, rhel-osp-director-maint, rsussman, sbaker, sclewis, shardy, sreichar, wayne_allen, yeylon, zbitter
Target Milestone: asyncKeywords: Triaged, ZStream
Target Release: 7.0 (Kilo)   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: openstack-heat-2015.1.1-6.el7ost Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1260990 Environment:
Last Closed: 2015-10-15 12:30:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1260990    
Bug Blocks:    

Comment 7 Amit Ugol 2015-10-14 10:52:04 UTC
the way that I tried to test it is this:
create a stack -> this created two raw templates
updated the stack with the same template, now we have 3 raw_templates
unless I missing something, this bug hasn't been fixed in this version.

tested in RHEL 7.1
version 2015.1.1-6.el7

after create and 1 update:

MariaDB [heat]> select * from raw_template\G;
*************************** 1. row ***************************
         id: 1
 created_at: 2015-10-14 10:35:11
 updated_at: NULL
   template: {"outputs": {"PublicKey": {"value": {"get_attr": ["KeyPair", "public_key"]}}, "PrivateKey": {"value": {"get_attr": ["KeyPair", "private_key"]}}}, "heat_template_version": "2013-05-23", "parameters": {"key_name": {"default": "heat_key_test", "type": "string"}, "key_save": {"default": false, "type": "string"}}, "resources": {"KeyPair": {"type": "OS::Nova::KeyPair", "properties": {"name": {"get_param": "key_name"}, "save_private_key": {"get_param": "key_save"}}}}}
      files: {}
environment: {"parameter_defaults": {}, "parameters": {}, "resource_registry": {"resources": {}}}
predecessor: NULL
*************************** 2. row ***************************
         id: 2
 created_at: 2015-10-14 10:38:37
 updated_at: NULL
   template: {"outputs": {"PublicKey": {"value": {"get_attr": ["KeyPair", "public_key"]}}, "PrivateKey": {"value": {"get_attr": ["KeyPair", "private_key"]}}}, "heat_template_version": "2013-05-23", "resources": {"KeyPair": {"type": "OS::Nova::KeyPair", "properties": {"name": {"get_param": "key_name"}, "save_private_key": {"get_param": "key_save"}}}}, "parameters": {"key_name": {"default": "heat_key_test", "type": "string"}, "key_save": {"default": false, "type": "string"}}}
      files: {}
environment: {"parameter_defaults": {}, "parameters": {}, "resource_registry": {"resources": {}}}
predecessor: NULL
*************************** 3. row ***************************
         id: 3
 created_at: 2015-10-14 10:38:39
 updated_at: NULL
   template: {"outputs": {"PublicKey": {"value": {"get_attr": ["KeyPair", "public_key"]}}, "PrivateKey": {"value": {"get_attr": ["KeyPair", "private_key"]}}}, "heat_template_version": "2013-05-23", "parameters": {"key_name": {"default": "heat_key_test", "type": "string"}, "key_save": {"default": false, "type": "string"}}, "resources": {"KeyPair": {"type": "OS::Nova::KeyPair", "properties": {"name": {"get_param": "key_name"}, "save_private_key": {"get_param": "key_save"}}}}}
      files: {}
environment: {"parameter_defaults": {}, "parameters": {}, "resource_registry": {"resources": {}}}
predecessor: NULL
3 rows in set (0.00 sec)


template that was used in this case:

heat_template_version: 2013-05-23

parameters:
  key_name:
    type: string
    default: heat_key_test
  key_save:
    type: string
    default: false

resources:
  KeyPair:
    type: OS::Nova::KeyPair
    properties:
      name: { get_param: key_name }
      save_private_key: { get_param: key_save }

outputs:
  PublicKey:
    value: { get_attr: [KeyPair, public_key] }
  PrivateKey:
    value: { get_attr: [KeyPair, private_key] }

Comment 8 Amit Ugol 2015-10-14 12:37:21 UTC
tested it better, thanks therve

Comment 9 Amit Ugol 2015-10-14 12:41:26 UTC
tested it better, thanks therve

Comment 10 Zane Bitter 2015-10-14 12:58:42 UTC
The bug wasn't about creating extra raw_template rows, but rather about doing multiple updates (with no actual change) to an existing row.

Also this test would not be sufficient to trigger the reported bug if it were present - it occurs only with Template resources (aka provider resources). There was a second issue fixed in this build that was also resulting in extra updates to the raw_template table which might have been triggered by this test, but I suspect it actually required something to be updated.

The two extra rows (timestamps suggest 1 from create and 2 from update, not the other way around) are expected - Heat creates a backup stack that has its own template, and because of soft deletes it doesn't get cleaned up as soon as we'd like it to (https://bugs.launchpad.net/heat/+bug/1332300). It also writes the new template at the end of the update - there may be a minor bug here in that we're not deleting the old one, but it's unrelated to the reported bug.

Comment 12 errata-xmlrpc 2015-10-15 12:30:25 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2015:1901