Merge "Don't deallocate network if destroy time out"
This commit is contained in:
@@ -117,6 +117,8 @@ VIR_FROM_REMOTE = 340
|
||||
VIR_FROM_RPC = 345
|
||||
VIR_ERR_XML_DETAIL = 350
|
||||
VIR_ERR_NO_DOMAIN = 420
|
||||
VIR_ERR_OPERATION_INVALID = 55
|
||||
VIR_ERR_OPERATION_TIMEOUT = 68
|
||||
VIR_ERR_NO_NWFILTER = 620
|
||||
VIR_ERR_SYSTEM_ERROR = 900
|
||||
VIR_ERR_INTERNAL_ERROR = 950
|
||||
|
||||
@@ -3421,6 +3421,27 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
"uuid": "875a8070-d0b9-4949-8b31-104d125c9a64"}
|
||||
conn.destroy(instance, [])
|
||||
|
||||
def test_destroy_timed_out(self):
|
||||
mock = self.mox.CreateMock(libvirt.virDomain)
|
||||
mock.ID()
|
||||
mock.destroy().AndRaise(libvirt.libvirtError("timed out"))
|
||||
self.mox.ReplayAll()
|
||||
|
||||
def fake_lookup_by_name(instance_name):
|
||||
return mock
|
||||
|
||||
def fake_get_error_code(self):
|
||||
return libvirt.VIR_ERR_OPERATION_TIMEOUT
|
||||
|
||||
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||
self.stubs.Set(conn, '_lookup_by_name', fake_lookup_by_name)
|
||||
self.stubs.Set(libvirt.libvirtError, 'get_error_code',
|
||||
fake_get_error_code)
|
||||
instance = {"name": "instancename", "id": "instanceid",
|
||||
"uuid": "875a8070-d0b9-4949-8b31-104d125c9a64"}
|
||||
self.assertRaises(exception.InstancePowerOffFailure,
|
||||
conn.destroy, instance, [])
|
||||
|
||||
def test_private_destroy_not_found(self):
|
||||
mock = self.mox.CreateMock(libvirt.virDomain)
|
||||
mock.ID()
|
||||
|
||||
@@ -776,6 +776,11 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
state = LIBVIRT_POWER_STATE[state]
|
||||
if state == power_state.SHUTDOWN:
|
||||
is_okay = True
|
||||
elif errcode == libvirt.VIR_ERR_OPERATION_TIMEOUT:
|
||||
LOG.warn(_("Cannot destroy instance, operation time out"),
|
||||
instance=instance)
|
||||
reason = _("operation time out")
|
||||
raise exception.InstancePowerOffFailure(reason=reason)
|
||||
|
||||
if not is_okay:
|
||||
with excutils.save_and_reraise_exception():
|
||||
|
||||
Reference in New Issue
Block a user