summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorramishra <ramishra@redhat.com>2021-04-01 10:19:31 +0530
committerRabi Mishra <ramishra@redhat.com>2021-04-02 05:36:58 +0000
commit7af71497ed15882a0f2a543cd8dd83c60b781f95 (patch)
tree3f0025f1c63c7855ae51e02ea65e8140f3dfee90
parent0bffa5c2e0e2f12264afebcadda0ec9617e9ed69 (diff)
downloadheat-7af71497ed15882a0f2a543cd8dd83c60b781f95.tar.gz
Don't update status for replaced resource
With I04e7ad90944c2d03ce0e59ba16af9d60d6e01222 we allowed update of previously-existing resource if replacement creation has failed during last update. However, we force update the status of the existing resource to 'COMPLETE'. Therefore, in the next update if properties/type has not changed for the resource it won't try to update/replace the previously existing resource resulting in false positive of stack updated successfully. Task: 42194 Change-Id: Icc90a921ec67e49aec2c4acfad72235c57c78421 (cherry picked from commit bfbaab107d709c37548a22239b952c6221b9ac85)
-rw-r--r--heat/db/sqlalchemy/api.py3
-rw-r--r--heat/engine/resource.py2
-rw-r--r--heat/objects/resource.py3
-rw-r--r--heat/tests/db/test_sqlalchemy_api.py6
4 files changed, 2 insertions, 12 deletions
diff --git a/heat/db/sqlalchemy/api.py b/heat/db/sqlalchemy/api.py
index 3672ce036..b79d2e30d 100644
--- a/heat/db/sqlalchemy/api.py
+++ b/heat/db/sqlalchemy/api.py
@@ -494,7 +494,7 @@ def resource_create(context, values):
@retry_on_db_error
def resource_create_replacement(context,
- existing_res_id, existing_res_values,
+ existing_res_id,
new_res_values,
atomic_key, expected_engine_id=None):
session = context.session
@@ -502,7 +502,6 @@ def resource_create_replacement(context,
with session.begin():
new_res = resource_create(context, new_res_values)
update_data = {'replaced_by': new_res.id}
- update_data.update(existing_res_values)
if not _try_resource_update(context,
existing_res_id, update_data,
atomic_key,
diff --git a/heat/engine/resource.py b/heat/engine/resource.py
index de9a708a8..b43b5a6a9 100644
--- a/heat/engine/resource.py
+++ b/heat/engine/resource.py
@@ -403,7 +403,6 @@ class Resource(status.ResourceStatus):
'current_template_id': new_tmpl_id,
'stack_name': self.stack.name,
'root_stack_id': self.root_stack_id}
- update_data = {'status': self.COMPLETE}
# Retry in case a signal has updated the atomic_key
attempts = max(cfg.CONF.client_retry_limit, 0) + 1
@@ -427,7 +426,6 @@ class Resource(status.ResourceStatus):
def create_replacement():
return resource_objects.Resource.replacement(self.context,
self.id,
- update_data,
rs,
self._atomic_key)
diff --git a/heat/objects/resource.py b/heat/objects/resource.py
index c99e572dc..c5aacd4fc 100644
--- a/heat/objects/resource.py
+++ b/heat/objects/resource.py
@@ -200,12 +200,11 @@ class Resource(
@classmethod
def replacement(cls, context,
- existing_res_id, existing_res_values,
+ existing_res_id,
new_res_values,
atomic_key=0, expected_engine_id=None):
replacement = db_api.resource_create_replacement(context,
existing_res_id,
- existing_res_values,
new_res_values,
atomic_key,
expected_engine_id)
diff --git a/heat/tests/db/test_sqlalchemy_api.py b/heat/tests/db/test_sqlalchemy_api.py
index 21fb8b55c..eef95d53c 100644
--- a/heat/tests/db/test_sqlalchemy_api.py
+++ b/heat/tests/db/test_sqlalchemy_api.py
@@ -2668,7 +2668,6 @@ class DBAPIResourceReplacementTest(common.HeatTestCase):
repl = db_api.resource_create_replacement(
self.ctx,
orig.id,
- {'status_reason': 'test replacement'},
{'name': orig.name, 'replaces': orig.id,
'stack_id': orig.stack_id, 'current_template_id': tmpl_id},
1, None)
@@ -2688,7 +2687,6 @@ class DBAPIResourceReplacementTest(common.HeatTestCase):
repl = db_api.resource_create_replacement(
self.ctx,
orig.id,
- {'status_reason': 'test replacement'},
{'name': orig.name, 'replaces': orig.id,
'stack_id': orig.stack_id, 'current_template_id': tmpl_id},
1, None)
@@ -2706,7 +2704,6 @@ class DBAPIResourceReplacementTest(common.HeatTestCase):
db_api.resource_create_replacement,
self.ctx,
orig.id,
- {'status_reason': 'test replacement'},
{'name': orig.name, 'replaces': orig.id,
'stack_id': orig.stack_id,
'current_template_id': tmpl_id},
@@ -2730,7 +2727,6 @@ class DBAPIResourceReplacementTest(common.HeatTestCase):
db_api.resource_create_replacement,
self.ctx,
orig.id,
- {'status_reason': 'test replacement'},
{'name': orig.name, 'replaces': orig.id,
'stack_id': orig.stack_id,
'current_template_id': tmpl_id},
@@ -2748,7 +2744,6 @@ class DBAPIResourceReplacementTest(common.HeatTestCase):
db_api.resource_create_replacement,
self.ctx,
orig.id,
- {'status_reason': 'test replacement'},
{'name': orig.name, 'replaces': orig.id,
'stack_id': orig.stack_id,
'current_template_id': tmpl_id},
@@ -2773,7 +2768,6 @@ class DBAPIResourceReplacementTest(common.HeatTestCase):
db_api.resource_create_replacement,
self.ctx,
orig.id,
- {'status_reason': 'test replacement'},
{'name': orig.name, 'replaces': orig.id,
'stack_id': orig.stack_id,
'current_template_id': tmpl_id},