Remove unnecessary destroy call from Ironic virt driver
To give some context, calling destroy [5] was added as a bug fix [1]. It was required back then because, Nova compute was not calling destroy on catching the exception [2]. But now, Nova compute catches all exceptions that happen during spawn and calls destroy (_shutdown_instance) [3] Since Nova compute is already taking care of destroying the instance before rescheduling, we shouldn't have to call destroy separately in the driver. I confirmed in logs that destroy gets called twice if there is any failure during _wait_for_active() [4] or timeout happens [5] [1] https://review.openstack.org/#/c/99519/ [2] https://github.com/openstack/nova/blob/2014.1.5/nova/compute/manager.py#L2116-L2118 [3] https://github.com/openstack/nova/blob/2015.1.2/nova/compute/manager.py#L2472-L2497 [4] https://github.com/openstack/nova/blob/2015.1.2/nova/virt/ironic/driver.py#L359-L384 [5] https://github.com/openstack/nova/blob/2015.1.2/nova/virt/ironic/driver.py#L730-L741 Closes-Bug: #1506234 Change-Id: I09da7910befc4167d9cf043d12b19432ed70bcac
This commit is contained in:
parent
4e8ea58e61
commit
a36001fbee
|
@ -895,7 +895,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
|||
self.assertRaises(
|
||||
exception.InstanceDeployFailure,
|
||||
self.driver.spawn, self.ctx, instance, None, [], None)
|
||||
mock_destroy.assert_called_once_with(self.ctx, instance, None)
|
||||
self.assertEqual(0, mock_destroy.call_count)
|
||||
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'update')
|
||||
def test__add_driver_fields_good(self, mock_update):
|
||||
|
@ -1128,8 +1128,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
|||
self.assertRaises(ironic_exception.BadRequest,
|
||||
self.driver.spawn, self.ctx, instance,
|
||||
image_meta, [], None, fake_net_info)
|
||||
mock_destroy.assert_called_once_with(self.ctx, instance,
|
||||
fake_net_info)
|
||||
self.assertEqual(0, mock_destroy.call_count)
|
||||
|
||||
@mock.patch.object(configdrive, 'required_by')
|
||||
@mock.patch.object(loopingcall, 'FixedIntervalLoopingCall')
|
||||
|
|
|
@ -833,7 +833,6 @@ class IronicDriver(virt_driver.ComputeDriver):
|
|||
"baremetal node %(node)s."),
|
||||
{'instance': instance.uuid,
|
||||
'node': node_uuid})
|
||||
self.destroy(context, instance, network_info)
|
||||
|
||||
def _unprovision(self, ironicclient, instance, node):
|
||||
"""This method is called from destroy() to unprovision
|
||||
|
|
Loading…
Reference in New Issue