Will not reraise error out when destroying a failed instance

Reraising an error would interrupt the process of removing
resources from the failed instance, and then make some resources
keep being occupied even after the instance has been deleted.

Change-Id: Id79eb4d58618987d9ae5e98a66f8339c423b4c4d
This commit is contained in:
Yi Chun Huang 2017-03-22 14:36:21 +08:00
parent 9a1ae9cbfd
commit 788bd4749d
2 changed files with 10 additions and 3 deletions

View File

@ -404,8 +404,10 @@ class ZVMDriverTestCases(ZVMTestCase):
("PUT", None, None, self._fake_reachable_data(': reachable')),
("DELETE", None, None, det_res)]
self._set_fake_xcat_resp(fake_resp_list)
self.assertRaises(exception.ZVMXCATInternalError,
self.driver.destroy, {}, self.instance, {}, {})
# Will not reraise xcat error anymore because it could interrupt the
# process of removing resources from the failed instance. Instead there
# will be a warning message in the log.
self.driver.destroy({}, self.instance, {}, {})
self.mox.VerifyAll()
def test_destroy_non_exist(self):

View File

@ -649,7 +649,12 @@ class ZVMDriver(driver.ComputeDriver):
"destroying z/VM instance %s"), inst_name,
instance=instance)
zvm_inst.delete_userid(self._get_hcp_info()['nodename'], context)
try:
nodename = self._get_hcp_info()['nodename']
zvm_inst.delete_userid(nodename, context)
except exception.ZVMBaseException as err:
LOG.warning(_LW("Failed to delete user node: %s"),
err.format_message(), instance=instance)
else:
LOG.warning(_LW('Instance %s does not exist'), inst_name,
instance=instance)