Merge "Prevent rescheduling on block device failure" into stable/havana
This commit is contained in:
commit
5a9551d91b
|
@ -1063,6 +1063,16 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||
instance_uuid=instance['uuid'], reason=msg)
|
||||
else:
|
||||
raise exc_info[0], exc_info[1], exc_info[2]
|
||||
except exception.InvalidBDM:
|
||||
with excutils.save_and_reraise_exception():
|
||||
if network_info is not None:
|
||||
network_info.wait(do_raise=False)
|
||||
try:
|
||||
self._deallocate_network(context, instance)
|
||||
except Exception:
|
||||
msg = _('Failed to dealloc network '
|
||||
'for failed instance')
|
||||
LOG.exception(msg, instance=instance)
|
||||
except Exception:
|
||||
exc_info = sys.exc_info()
|
||||
# try to re-schedule instance:
|
||||
|
@ -1388,9 +1398,9 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||
return block_device_info
|
||||
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_('Instance failed block device setup'),
|
||||
instance=instance)
|
||||
LOG.exception(_('Instance failed block device setup'),
|
||||
instance=instance)
|
||||
raise exception.InvalidBDM()
|
||||
|
||||
def _spawn(self, context, instance, image_meta, network_info,
|
||||
block_device_info, injected_files, admin_password,
|
||||
|
|
|
@ -1356,11 +1356,11 @@ class ComputeTestCase(BaseTestCase):
|
|||
the instance goes to ERROR state, keeping the task state
|
||||
"""
|
||||
def fake(*args, **kwargs):
|
||||
raise test.TestingException()
|
||||
raise exception.InvalidBDM()
|
||||
self.stubs.Set(nova.compute.manager.ComputeManager,
|
||||
'_prep_block_device', fake)
|
||||
instance = self._create_fake_instance()
|
||||
self.assertRaises(test.TestingException, self.compute.run_instance,
|
||||
self.assertRaises(exception.InvalidBDM, self.compute.run_instance,
|
||||
self.context, instance=instance)
|
||||
#check state is failed even after the periodic poll
|
||||
self._assert_state({'vm_state': vm_states.ERROR,
|
||||
|
@ -9003,6 +9003,20 @@ class ComputeRescheduleOrErrorTestCase(BaseTestCase):
|
|||
self.compute._run_instance, self.context, None, {}, None, None,
|
||||
None, False, None, self.instance, False)
|
||||
|
||||
def test_no_reschedule_on_block_device_fail(self):
|
||||
self.mox.StubOutWithMock(self.compute, '_prep_block_device')
|
||||
self.mox.StubOutWithMock(self.compute, '_reschedule_or_error')
|
||||
|
||||
exc = exception.InvalidBDM()
|
||||
|
||||
self.compute._prep_block_device(mox.IgnoreArg(), self.instance,
|
||||
mox.IgnoreArg()).AndRaise(exc)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
self.assertRaises(exception.InvalidBDM, self.compute._run_instance,
|
||||
self.context, None, {}, None, None, None, False,
|
||||
None, self.instance, False)
|
||||
|
||||
|
||||
class ComputeRescheduleResizeOrReraiseTestCase(BaseTestCase):
|
||||
"""Test logic and exception handling around rescheduling prep resize
|
||||
|
|
Loading…
Reference in New Issue