Merge "Don't update RT status when set instance to ERROR"
This commit is contained in:
commit
50bc9dcea8
|
@ -728,16 +728,6 @@ class ComputeManager(manager.Manager):
|
|||
self._update_resource_tracker(context, instance_ref)
|
||||
return instance_ref
|
||||
|
||||
def _set_instance_error_state(self, context, instance):
|
||||
instance_uuid = instance.uuid
|
||||
try:
|
||||
self._instance_update(context, instance_uuid,
|
||||
vm_state=vm_states.ERROR)
|
||||
except exception.InstanceNotFound:
|
||||
LOG.debug('Instance has been destroyed from under us while '
|
||||
'trying to set it to ERROR',
|
||||
instance_uuid=instance_uuid)
|
||||
|
||||
def _set_instance_obj_error_state(self, context, instance):
|
||||
try:
|
||||
instance.vm_state = vm_states.ERROR
|
||||
|
@ -1011,7 +1001,7 @@ class ComputeManager(manager.Manager):
|
|||
# we don't want that an exception blocks the init_host
|
||||
msg = _LE('Failed to complete a deletion')
|
||||
LOG.exception(msg, instance=instance)
|
||||
self._set_instance_error_state(context, instance)
|
||||
self._set_instance_obj_error_state(context, instance)
|
||||
return
|
||||
|
||||
try_reboot, reboot_type = self._retry_reboot(context, instance)
|
||||
|
@ -1093,7 +1083,7 @@ class ComputeManager(manager.Manager):
|
|||
except exception.VirtualInterfacePlugException:
|
||||
# we don't want an exception to block the init_host
|
||||
LOG.exception(_LE("Vifs plug failed"), instance=instance)
|
||||
self._set_instance_error_state(context, instance)
|
||||
self._set_instance_obj_error_state(context, instance)
|
||||
return
|
||||
|
||||
if instance.task_state == task_states.RESIZE_MIGRATING:
|
||||
|
@ -1154,7 +1144,7 @@ class ComputeManager(manager.Manager):
|
|||
# instance to error and attempt to continue.
|
||||
LOG.warning(_LW('Failed to resume instance'),
|
||||
instance=instance)
|
||||
self._set_instance_error_state(context, instance)
|
||||
self._set_instance_obj_error_state(context, instance)
|
||||
|
||||
elif drv_state == power_state.RUNNING:
|
||||
# VMwareAPI drivers will raise an exception
|
||||
|
@ -1495,7 +1485,7 @@ class ComputeManager(manager.Manager):
|
|||
|
||||
for instance in building_insts:
|
||||
if timeutils.is_older_than(instance.created_at, timeout):
|
||||
self._set_instance_error_state(context, instance)
|
||||
self._set_instance_obj_error_state(context, instance)
|
||||
LOG.warning(_LW("Instance build timed out. Set to error "
|
||||
"state."), instance=instance)
|
||||
|
||||
|
@ -2167,7 +2157,7 @@ class ComputeManager(manager.Manager):
|
|||
with excutils.save_and_reraise_exception():
|
||||
LOG.error(_LE('Failed to deallocate network for instance.'),
|
||||
instance=instance)
|
||||
self._set_instance_error_state(context, instance)
|
||||
self._set_instance_obj_error_state(context, instance)
|
||||
|
||||
def _get_power_off_values(self, context, instance, clean_shutdown):
|
||||
"""Get the timing configuration for powering down this instance."""
|
||||
|
@ -2379,7 +2369,7 @@ class ComputeManager(manager.Manager):
|
|||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(_LE('Setting instance vm_state to ERROR'),
|
||||
instance=instance)
|
||||
self._set_instance_error_state(context, instance)
|
||||
self._set_instance_obj_error_state(context, instance)
|
||||
|
||||
do_terminate_instance(instance, bdms)
|
||||
|
||||
|
@ -3492,7 +3482,7 @@ class ComputeManager(manager.Manager):
|
|||
filter_properties = {}
|
||||
|
||||
if not instance.host:
|
||||
self._set_instance_error_state(context, instance)
|
||||
self._set_instance_obj_error_state(context, instance)
|
||||
msg = _('Instance has no source host')
|
||||
raise exception.MigrationError(reason=msg)
|
||||
|
||||
|
@ -3504,7 +3494,7 @@ class ComputeManager(manager.Manager):
|
|||
raise exception.UnableToMigrateToSelf(
|
||||
instance_id=instance.uuid, host=self.host)
|
||||
elif same_host and not CONF.allow_resize_to_same_host:
|
||||
self._set_instance_error_state(context, instance)
|
||||
self._set_instance_obj_error_state(context, instance)
|
||||
msg = _('destination same as source!')
|
||||
raise exception.MigrationError(reason=msg)
|
||||
|
||||
|
@ -3820,7 +3810,7 @@ class ComputeManager(manager.Manager):
|
|||
LOG.exception(_LE("Failed to rollback quota for failed "
|
||||
"finish_resize"),
|
||||
instance=instance)
|
||||
self._set_instance_error_state(context, instance)
|
||||
self._set_instance_obj_error_state(context, instance)
|
||||
|
||||
@wrap_exception()
|
||||
@wrap_instance_fault
|
||||
|
@ -6194,7 +6184,7 @@ class ComputeManager(manager.Manager):
|
|||
with excutils.save_and_reraise_exception():
|
||||
if quotas:
|
||||
quotas.rollback()
|
||||
self._set_instance_error_state(context, instance)
|
||||
self._set_instance_obj_error_state(context, instance)
|
||||
|
||||
@wrap_exception()
|
||||
def add_aggregate_host(self, context, aggregate, host, slave_info):
|
||||
|
|
|
@ -6542,24 +6542,15 @@ class ComputeTestCase(BaseTestCase):
|
|||
new_instance.update(filters)
|
||||
instances.append(fake_instance.fake_db_instance(**new_instance))
|
||||
|
||||
# need something to return from conductor_api.instance_update
|
||||
# that is defined outside the for loop and can be used in the mock
|
||||
# context
|
||||
fake_instance_ref = {'host': CONF.host, 'node': 'fake'}
|
||||
|
||||
# creating mocks
|
||||
with contextlib.nested(
|
||||
mock.patch.object(self.compute.db.sqlalchemy.api,
|
||||
'instance_get_all_by_filters',
|
||||
return_value=instances),
|
||||
mock.patch.object(self.compute.conductor_api, 'instance_update',
|
||||
return_value=fake_instance_ref),
|
||||
mock.patch.object(self.compute.driver, 'node_is_available',
|
||||
return_value=False)
|
||||
mock.patch.object(objects.Instance, 'save'),
|
||||
) as (
|
||||
instance_get_all_by_filters,
|
||||
conductor_instance_update,
|
||||
node_is_available
|
||||
conductor_instance_update
|
||||
):
|
||||
# run the code
|
||||
self.compute._check_instance_build_time(ctxt)
|
||||
|
@ -6574,14 +6565,9 @@ class ComputeTestCase(BaseTestCase):
|
|||
limit=None)
|
||||
self.assertThat(conductor_instance_update.mock_calls,
|
||||
testtools_matchers.HasLength(len(old_instances)))
|
||||
self.assertThat(node_is_available.mock_calls,
|
||||
testtools_matchers.HasLength(len(old_instances)))
|
||||
for inst in old_instances:
|
||||
conductor_instance_update.assert_has_calls([
|
||||
mock.call(ctxt, inst['uuid'],
|
||||
vm_state=vm_states.ERROR)])
|
||||
node_is_available.assert_has_calls([
|
||||
mock.call(fake_instance_ref['node'])])
|
||||
mock.call()])
|
||||
|
||||
def test_get_resource_tracker_fail(self):
|
||||
self.assertRaises(exception.NovaException,
|
||||
|
|
|
@ -539,7 +539,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
mock.patch.object(self.compute.driver, 'plug_vifs',
|
||||
side_effect=exception.VirtualInterfacePlugException(
|
||||
"Unexpected vif_type=binding_failed")),
|
||||
mock.patch.object(self.compute, '_set_instance_error_state')
|
||||
mock.patch.object(self.compute, '_set_instance_obj_error_state')
|
||||
) as (get_admin_context, get_nw_info, plug_vifs, set_error_state):
|
||||
self.compute._init_instance(self.context, instance)
|
||||
set_error_state.assert_called_once_with(self.context, instance)
|
||||
|
@ -585,7 +585,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
self.mox.StubOutWithMock(self.compute,
|
||||
'_get_instance_block_device_info')
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_set_instance_error_state')
|
||||
'_set_instance_obj_error_state')
|
||||
self.compute._get_power_state(mox.IgnoreArg(),
|
||||
instance).AndReturn(power_state.SHUTDOWN)
|
||||
self.compute._get_power_state(mox.IgnoreArg(),
|
||||
|
@ -598,7 +598,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
self.compute.driver.resume_state_on_host_boot(mox.IgnoreArg(),
|
||||
instance, mox.IgnoreArg(),
|
||||
'fake-bdm').AndRaise(test.TestingException)
|
||||
self.compute._set_instance_error_state(mox.IgnoreArg(), instance)
|
||||
self.compute._set_instance_obj_error_state(mox.IgnoreArg(), instance)
|
||||
self.mox.ReplayAll()
|
||||
self.compute._init_instance('fake-context', instance)
|
||||
|
||||
|
@ -664,7 +664,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
|
||||
mock_delete_instance = _create_patch(self.compute, '_delete_instance')
|
||||
mock_set_instance_error_state = _create_patch(
|
||||
self.compute, '_set_instance_error_state')
|
||||
self.compute, '_set_instance_obj_error_state')
|
||||
mock_create_reservations = _create_patch(self.compute,
|
||||
'_create_reservations')
|
||||
|
||||
|
@ -1448,7 +1448,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
f_instance.info_cache.network_info = []
|
||||
|
||||
@mock.patch.object(compute_utils, 'add_instance_fault_from_exc')
|
||||
@mock.patch.object(self.compute, '_set_instance_error_state')
|
||||
@mock.patch.object(self.compute, '_set_instance_obj_error_state')
|
||||
def do_test(meth, add_fault):
|
||||
self.assertRaises(exception.PortNotFound,
|
||||
self.compute.detach_interface,
|
||||
|
@ -2341,7 +2341,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
vm_state=vm_states.ACTIVE, task_state=None)
|
||||
|
||||
@mock.patch('nova.compute.manager.ComputeManager.'
|
||||
'_set_instance_error_state')
|
||||
'_set_instance_obj_error_state')
|
||||
def test_error_out_instance_on_exception_unknown_with_quotas(self,
|
||||
set_error):
|
||||
instance = fake_instance.fake_instance_obj(self.context)
|
||||
|
@ -3737,10 +3737,11 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
|||
side_effect=exception.ResizeError(reason='')),
|
||||
mock.patch.object(db, 'instance_fault_create'),
|
||||
mock.patch.object(self.compute, '_instance_update'),
|
||||
mock.patch.object(self.instance, 'save'),
|
||||
mock.patch.object(self.migration, 'save'),
|
||||
mock.patch.object(self.migration, 'obj_as_admin',
|
||||
return_value=mock.MagicMock())
|
||||
) as (meth, fault_create, instance_update,
|
||||
) as (meth, fault_create, instance_update, instance_save,
|
||||
migration_save, migration_obj_as_admin):
|
||||
fault_create.return_value = (
|
||||
test_instance_fault.fake_faults['fake-uuid'][0])
|
||||
|
|
Loading…
Reference in New Issue