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 bfbaab107d
)
This commit is contained in:
parent
ede47008bc
commit
ba2ed09ba1
|
@ -457,7 +457,7 @@ def resource_create(context, values):
|
|||
@oslo_db_api.wrap_db_retry(max_retries=3, retry_on_deadlock=True,
|
||||
retry_interval=0.5, inc_retry_interval=True)
|
||||
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
|
||||
|
@ -465,7 +465,6 @@ def resource_create_replacement(context,
|
|||
with session.begin(subtransactions=True):
|
||||
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,
|
||||
|
|
|
@ -405,7 +405,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
|
||||
|
@ -429,7 +428,6 @@ class Resource(status.ResourceStatus):
|
|||
def create_replacement():
|
||||
return resource_objects.Resource.replacement(self.context,
|
||||
self.id,
|
||||
update_data,
|
||||
rs,
|
||||
self._atomic_key)
|
||||
|
||||
|
|
|
@ -201,12 +201,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)
|
||||
|
|
|
@ -2631,7 +2631,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)
|
||||
|
@ -2651,7 +2650,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)
|
||||
|
@ -2669,7 +2667,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},
|
||||
|
@ -2693,7 +2690,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},
|
||||
|
@ -2711,7 +2707,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},
|
||||
|
@ -2736,7 +2731,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},
|
||||
|
|
Loading…
Reference in New Issue