Always check for 'component' in SoftwareDeployment
When SoftwareDeployment is associated to a SoftwareComponent, config hooks in the instance should always be trigger and the in-instance logic will decide whether or not anything has to be done. The check whether the SoftwareDeployment resource is associated to a SoftwareComponent resource is implemented in _handle_action which is called by all handle_ methods. For handle_delete, however, the 'actions' property of SoftwareDeployment was evaluated first and only if it contained DELETE the _handle_action method was invoked. This patch make handle_delete also directly call _handle_action to check for presence of a SoftwareComponent like all other lifecycle hooks do. Change-Id: Ibb813db23fa7c9ab20435887f6cc49deaaf51de2 Closes-Bug: #1416994
This commit is contained in:
parent
29dd42e923
commit
0f58b65e19
|
@ -398,13 +398,10 @@ class SoftwareDeployment(signal_responder.SignalResponder):
|
||||||
return self._check_complete()
|
return self._check_complete()
|
||||||
|
|
||||||
def handle_delete(self):
|
def handle_delete(self):
|
||||||
if self.DELETE in self.properties[self.DEPLOY_ACTIONS]:
|
|
||||||
try:
|
try:
|
||||||
return self._handle_action(self.DELETE)
|
return self._handle_action(self.DELETE)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.rpc_client().ignore_error_named(ex, 'NotFound')
|
self.rpc_client().ignore_error_named(ex, 'NotFound')
|
||||||
else:
|
|
||||||
self._delete_resource()
|
|
||||||
|
|
||||||
def check_delete_complete(self, sd=None):
|
def check_delete_complete(self, sd=None):
|
||||||
if not sd or self._check_complete():
|
if not sd or self._check_complete():
|
||||||
|
|
|
@ -482,7 +482,7 @@ class SoftwareDeploymentTest(common.HeatTestCase):
|
||||||
|
|
||||||
self.deployment.resource_id = sd['id']
|
self.deployment.resource_id = sd['id']
|
||||||
self.deployment.handle_delete()
|
self.deployment.handle_delete()
|
||||||
|
self.deployment.check_delete_complete()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
(self.ctx, sd['id']),
|
(self.ctx, sd['id']),
|
||||||
self.rpc_client.delete_software_deployment.call_args[0])
|
self.rpc_client.delete_software_deployment.call_args[0])
|
||||||
|
@ -528,6 +528,7 @@ class SoftwareDeploymentTest(common.HeatTestCase):
|
||||||
self.rpc_client.delete_software_deployment.side_effect = nf
|
self.rpc_client.delete_software_deployment.side_effect = nf
|
||||||
self.rpc_client.delete_software_config.side_effect = nf
|
self.rpc_client.delete_software_config.side_effect = nf
|
||||||
self.assertIsNone(self.deployment.handle_delete())
|
self.assertIsNone(self.deployment.handle_delete())
|
||||||
|
self.assertTrue(self.deployment.check_delete_complete())
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
(self.ctx, derived_sc['id']),
|
(self.ctx, derived_sc['id']),
|
||||||
self.rpc_client.delete_software_config.call_args[0])
|
self.rpc_client.delete_software_config.call_args[0])
|
||||||
|
@ -828,19 +829,49 @@ class SoftwareDeploymentTest(common.HeatTestCase):
|
||||||
self._create_stack(self.template)
|
self._create_stack(self.template)
|
||||||
|
|
||||||
self.mock_software_config()
|
self.mock_software_config()
|
||||||
|
sd = self.mock_deployment()
|
||||||
|
rsrc = self.stack['deployment_mysql']
|
||||||
|
|
||||||
for action in ('DELETE', 'SUSPEND', 'RESUME'):
|
self.rpc_client.show_software_deployment.return_value = sd
|
||||||
self.assertIsNone(self.deployment._handle_action(action))
|
self.deployment.resource_id = sd['id']
|
||||||
for action in ('CREATE', 'UPDATE'):
|
config_id = '0ff2e903-78d7-4cca-829e-233af3dae705'
|
||||||
self.assertIsNotNone(self.deployment._handle_action(action))
|
prop_diff = {'config': config_id}
|
||||||
|
props = copy.copy(rsrc.properties.data)
|
||||||
|
props.update(prop_diff)
|
||||||
|
snippet = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(), props)
|
||||||
|
|
||||||
|
# by default (no 'actions' property) SoftwareDeployment must only
|
||||||
|
# trigger for CREATE and UPDATE
|
||||||
|
self.assertIsNotNone(self.deployment.handle_create())
|
||||||
|
self.assertIsNotNone(self.deployment.handle_update(
|
||||||
|
json_snippet=snippet, tmpl_diff=None, prop_diff=prop_diff))
|
||||||
|
# ... but it must not trigger for SUSPEND, RESUME and DELETE
|
||||||
|
self.assertIsNone(self.deployment.handle_suspend())
|
||||||
|
self.assertIsNone(self.deployment.handle_resume())
|
||||||
|
self.assertIsNone(self.deployment.handle_delete())
|
||||||
|
|
||||||
def test_handle_action_for_component(self):
|
def test_handle_action_for_component(self):
|
||||||
self._create_stack(self.template)
|
self._create_stack(self.template)
|
||||||
|
|
||||||
self.mock_software_component()
|
self.mock_software_component()
|
||||||
|
sd = self.mock_deployment()
|
||||||
|
rsrc = self.stack['deployment_mysql']
|
||||||
|
|
||||||
for action in ('CREATE', 'UPDATE', 'DELETE', 'SUSPEND', 'RESUME'):
|
self.rpc_client.show_software_deployment.return_value = sd
|
||||||
self.assertIsNotNone(self.deployment._handle_action(action))
|
self.deployment.resource_id = sd['id']
|
||||||
|
config_id = '0ff2e903-78d7-4cca-829e-233af3dae705'
|
||||||
|
prop_diff = {'config': config_id}
|
||||||
|
props = copy.copy(rsrc.properties.data)
|
||||||
|
props.update(prop_diff)
|
||||||
|
snippet = rsrc_defn.ResourceDefinition(rsrc.name, rsrc.type(), props)
|
||||||
|
|
||||||
|
# for a SoftwareComponent, SoftwareDeployment must always trigger
|
||||||
|
self.assertIsNotNone(self.deployment.handle_create())
|
||||||
|
self.assertIsNotNone(self.deployment.handle_update(
|
||||||
|
json_snippet=snippet, tmpl_diff=None, prop_diff=prop_diff))
|
||||||
|
self.assertIsNotNone(self.deployment.handle_suspend())
|
||||||
|
self.assertIsNotNone(self.deployment.handle_resume())
|
||||||
|
self.assertIsNotNone(self.deployment.handle_delete())
|
||||||
|
|
||||||
|
|
||||||
class SoftwareDeploymentsTest(common.HeatTestCase):
|
class SoftwareDeploymentsTest(common.HeatTestCase):
|
||||||
|
|
Loading…
Reference in New Issue