libvirt: cleanup() serial_consoles after instance failure
When nova cleanup() is called to release all resources related to an instance it can thow InstanceNotFound. Which is not caught and therefore returned to the user. This is because the generator function (_get_serial_ports_from_instance) is not *executed* under try/except. While that is clearly the intent of the code. Change-Id: I9e9410ab7eec5fa667c0c3de4548c49df050c167 Closes-Bug: 1480514
This commit is contained in:
parent
026cc5a86b
commit
d365c087ae
|
@ -10946,7 +10946,10 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
|||
|
||||
# Ensure _get_serial_ports_from_instance raises same exception
|
||||
# that would have occurred if domain was gone.
|
||||
get_ports.side_effect = exception.InstanceNotFound("domain undefined")
|
||||
def exception_with_yield(instance):
|
||||
raise exception.InstanceNotFound("domain undefined")
|
||||
yield
|
||||
get_ports.side_effect = exception_with_yield
|
||||
|
||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI())
|
||||
drvr.firewall_driver = firewall_driver
|
||||
|
|
|
@ -884,11 +884,10 @@ class LibvirtDriver(driver.ComputeDriver):
|
|||
if CONF.serial_console.enabled:
|
||||
try:
|
||||
serials = self._get_serial_ports_from_instance(instance)
|
||||
for hostname, port in serials:
|
||||
serial_console.release_port(host=hostname, port=port)
|
||||
except exception.InstanceNotFound:
|
||||
# Serial ports already gone. Nothing to release.
|
||||
serials = ()
|
||||
for hostname, port in serials:
|
||||
serial_console.release_port(host=hostname, port=port)
|
||||
pass
|
||||
|
||||
self._undefine_domain(instance)
|
||||
|
||||
|
|
Loading…
Reference in New Issue