Merge "Fix rebuild of baremetal instance when vm_state is ERROR"
This commit is contained in:
commit
ba3147420c
|
@ -240,6 +240,23 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||||
fake_validate.assert_called_once_with(instance)
|
fake_validate.assert_called_once_with(instance)
|
||||||
fake_refresh.assert_called_once_with()
|
fake_refresh.assert_called_once_with()
|
||||||
|
|
||||||
|
@mock.patch.object(objects.Instance, 'refresh')
|
||||||
|
@mock.patch.object(ironic_driver.IronicDriver,
|
||||||
|
'_validate_instance_and_node')
|
||||||
|
def test__wait_for_active_from_error(self, fake_validate, fake_refresh):
|
||||||
|
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||||
|
uuid=uuidutils.generate_uuid(),
|
||||||
|
vm_state=vm_states.ERROR,
|
||||||
|
task_state=task_states.REBUILD_SPAWNING)
|
||||||
|
node = ironic_utils.get_test_node(
|
||||||
|
provision_state=ironic_states.ACTIVE)
|
||||||
|
|
||||||
|
fake_validate.return_value = node
|
||||||
|
self.assertRaises(loopingcall.LoopingCallDone,
|
||||||
|
self.driver._wait_for_active, instance)
|
||||||
|
fake_validate.assert_called_once_with(instance)
|
||||||
|
fake_refresh.assert_called_once_with()
|
||||||
|
|
||||||
@mock.patch.object(objects.Instance, 'refresh')
|
@mock.patch.object(objects.Instance, 'refresh')
|
||||||
@mock.patch.object(ironic_driver.IronicDriver,
|
@mock.patch.object(ironic_driver.IronicDriver,
|
||||||
'_validate_instance_and_node')
|
'_validate_instance_and_node')
|
||||||
|
@ -275,7 +292,8 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||||
self._wait_for_active_abort({'vm_state': vm_states.DELETED})
|
self._wait_for_active_abort({'vm_state': vm_states.DELETED})
|
||||||
|
|
||||||
def test__wait_for_active_abort_error(self):
|
def test__wait_for_active_abort_error(self):
|
||||||
self._wait_for_active_abort({'vm_state': vm_states.ERROR})
|
self._wait_for_active_abort({'task_state': task_states.SPAWNING,
|
||||||
|
'vm_state': vm_states.ERROR})
|
||||||
|
|
||||||
@mock.patch.object(ironic_driver.IronicDriver,
|
@mock.patch.object(ironic_driver.IronicDriver,
|
||||||
'_validate_instance_and_node')
|
'_validate_instance_and_node')
|
||||||
|
|
|
@ -525,8 +525,10 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||||
def _wait_for_active(self, instance):
|
def _wait_for_active(self, instance):
|
||||||
"""Wait for the node to be marked as ACTIVE in Ironic."""
|
"""Wait for the node to be marked as ACTIVE in Ironic."""
|
||||||
instance.refresh()
|
instance.refresh()
|
||||||
if (instance.task_state == task_states.DELETING or
|
# Ignore REBUILD_SPAWNING when rebuilding from ERROR state.
|
||||||
instance.vm_state in (vm_states.ERROR, vm_states.DELETED)):
|
if (instance.task_state != task_states.REBUILD_SPAWNING and
|
||||||
|
(instance.task_state == task_states.DELETING or
|
||||||
|
instance.vm_state in (vm_states.ERROR, vm_states.DELETED))):
|
||||||
raise exception.InstanceDeployFailure(
|
raise exception.InstanceDeployFailure(
|
||||||
_("Instance %s provisioning was aborted") % instance.uuid)
|
_("Instance %s provisioning was aborted") % instance.uuid)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue