diff --git a/nova/cells/manager.py b/nova/cells/manager.py index fd3fb76688c6..791fcea562d0 100644 --- a/nova/cells/manager.py +++ b/nova/cells/manager.py @@ -236,10 +236,6 @@ class CellsManager(manager.Manager): self.msg_runner.instance_delete_everywhere(ctxt, instance, delete_type) - def instance_fault_create_at_top(self, ctxt, instance_fault): - """Create an instance fault at the top level cell.""" - self.msg_runner.instance_fault_create_at_top(ctxt, instance_fault) - def bw_usage_update_at_top(self, ctxt, bw_update_info): """Update bandwidth usage at top level cell.""" self.msg_runner.bw_usage_update_at_top(ctxt, bw_update_info) diff --git a/nova/cells/messaging.py b/nova/cells/messaging.py index 7c80eb06f8db..b0f4c5201435 100644 --- a/nova/cells/messaging.py +++ b/nova/cells/messaging.py @@ -1084,18 +1084,6 @@ class _BroadcastMessageMethods(_BaseMessageMethods): else: self.compute_api.delete(message.ctxt, instance) - def instance_fault_create_at_top(self, message, instance_fault, **kwargs): - """Destroy an instance from the DB if we're a top level cell.""" - if not self._at_the_top(): - return - items_to_remove = ['id'] - for key in items_to_remove: - instance_fault.pop(key, None) - LOG.debug("Got message to create instance fault: %s", instance_fault) - fault = objects.InstanceFault(context=message.ctxt) - fault.update(instance_fault) - fault.create() - def bw_usage_update_at_top(self, message, bw_update_info, **kwargs): """Update Bandwidth usage in the DB if we're a top level cell.""" if not self._at_the_top(): @@ -1406,14 +1394,6 @@ class MessageRunner(object): run_locally=False) message.process() - def instance_fault_create_at_top(self, ctxt, instance_fault): - """Create an instance fault at the top level cell.""" - message = _BroadcastMessage(self, ctxt, - 'instance_fault_create_at_top', - dict(instance_fault=instance_fault), - 'up', run_locally=False) - message.process() - def bw_usage_update_at_top(self, ctxt, bw_update_info): """Update bandwidth usage at top level cell.""" message = _BroadcastMessage(self, ctxt, 'bw_usage_update_at_top', diff --git a/nova/cells/rpcapi.py b/nova/cells/rpcapi.py index e781ba452e8d..124dbf21685d 100644 --- a/nova/cells/rpcapi.py +++ b/nova/cells/rpcapi.py @@ -234,12 +234,6 @@ class CellsAPI(object): cctxt.cast(ctxt, 'instance_delete_everywhere', instance=instance, delete_type=delete_type) - def instance_fault_create_at_top(self, ctxt, instance_fault): - """Create an instance fault at the top.""" - instance_fault_p = jsonutils.to_primitive(instance_fault) - self.client.cast(ctxt, 'instance_fault_create_at_top', - instance_fault=instance_fault_p) - def bw_usage_update_at_top(self, ctxt, uuid, mac, start_period, bw_in, bw_out, last_ctr_in, last_ctr_out, last_refreshed=None): """Broadcast upwards that bw_usage was updated.""" diff --git a/nova/objects/instance_fault.py b/nova/objects/instance_fault.py index 3010145e7e3e..0c2d9bc15dd6 100644 --- a/nova/objects/instance_fault.py +++ b/nova/objects/instance_fault.py @@ -16,8 +16,6 @@ import itertools from oslo_log import log as logging -from nova.cells import opts as cells_opts -from nova.cells import rpcapi as cells_rpcapi from nova.db import api as db from nova import exception from nova import objects @@ -78,16 +76,6 @@ class InstanceFault(base.NovaPersistentObject, base.NovaObject, db_fault = db.instance_fault_create(self._context, values) self._from_db_object(self._context, self, db_fault) self.obj_reset_changes() - # Cells should only try sending a message over to nova-cells - # if cells is enabled and we're not the API cell. Otherwise, - # if the API cell is calling this, we could end up with - # infinite recursion. - if cells_opts.get_cell_type() == 'compute': - try: - cells_rpcapi.CellsAPI().instance_fault_create_at_top( - self._context, db_fault) - except Exception: - LOG.exception("Failed to notify cells of instance fault") @base.NovaObjectRegistry.register diff --git a/nova/tests/unit/cells/test_cells_manager.py b/nova/tests/unit/cells/test_cells_manager.py index d1e9ec72f112..010878fe9cbe 100644 --- a/nova/tests/unit/cells/test_cells_manager.py +++ b/nova/tests/unit/cells/test_cells_manager.py @@ -187,15 +187,6 @@ class CellsManagerClassTestCase(test.NoDBTestCase): self.ctxt, instance='fake-instance', delete_type='fake-type') - def test_instance_fault_create_at_top(self): - self.mox.StubOutWithMock(self.msg_runner, - 'instance_fault_create_at_top') - self.msg_runner.instance_fault_create_at_top(self.ctxt, - 'fake-fault') - self.mox.ReplayAll() - self.cells_manager.instance_fault_create_at_top( - self.ctxt, instance_fault='fake-fault') - def test_bw_usage_update_at_top(self): self.mox.StubOutWithMock(self.msg_runner, 'bw_usage_update_at_top') diff --git a/nova/tests/unit/cells/test_cells_messaging.py b/nova/tests/unit/cells/test_cells_messaging.py index ad4b6c6ae68f..b294818013cd 100644 --- a/nova/tests/unit/cells/test_cells_messaging.py +++ b/nova/tests/unit/cells/test_cells_messaging.py @@ -1620,29 +1620,6 @@ class CellsBroadcastMethodsTestCase(test.NoDBTestCase): self.src_msg_runner.instance_delete_everywhere(self.ctxt, instance, 'soft') - def test_instance_fault_create_at_top(self): - fake_instance_fault = {'id': 1, - 'message': 'fake-message', - 'details': 'fake-details'} - - if_mock = mock.Mock(spec_set=objects.InstanceFault) - - def _check_create(): - self.assertEqual('fake-message', if_mock.message) - self.assertEqual('fake-details', if_mock.details) - # Should not be set - self.assertNotEqual(1, if_mock.id) - - if_mock.create.side_effect = _check_create - - with mock.patch.object(objects, 'InstanceFault') as if_obj_mock: - if_obj_mock.return_value = if_mock - self.src_msg_runner.instance_fault_create_at_top( - self.ctxt, fake_instance_fault) - - if_obj_mock.assert_called_once_with(context=self.ctxt) - if_mock.create.assert_called_once_with() - def test_bw_usage_update_at_top(self): fake_bw_update_info = {'uuid': 'fake_uuid', 'mac': 'fake_mac', diff --git a/nova/tests/unit/cells/test_cells_rpcapi.py b/nova/tests/unit/cells/test_cells_rpcapi.py index 4c02ccb9adf4..4f54c865f398 100644 --- a/nova/tests/unit/cells/test_cells_rpcapi.py +++ b/nova/tests/unit/cells/test_cells_rpcapi.py @@ -199,19 +199,6 @@ class CellsAPITestCase(test.NoDBTestCase): self._check_result(call_info, 'instance_delete_everywhere', expected_args, version='1.27') - def test_instance_fault_create_at_top(self): - fake_instance_fault = {'id': 2, - 'other': 'meow'} - - call_info = self._stub_rpc_method('cast', None) - - self.cells_rpcapi.instance_fault_create_at_top( - self.fake_context, fake_instance_fault) - - expected_args = {'instance_fault': fake_instance_fault} - self._check_result(call_info, 'instance_fault_create_at_top', - expected_args) - def test_bw_usage_update_at_top(self): update_args = ('fake_uuid', 'fake_mac', 'fake_start_period', 'fake_bw_in', 'fake_bw_out', 'fake_ctr_in', diff --git a/nova/tests/unit/objects/test_instance_fault.py b/nova/tests/unit/objects/test_instance_fault.py index e16a61b2d921..767071760f0f 100644 --- a/nova/tests/unit/objects/test_instance_fault.py +++ b/nova/tests/unit/objects/test_instance_fault.py @@ -72,9 +72,8 @@ class _TestInstanceFault(object): self.assertEqual(0, len(faults)) get_mock.assert_called_once_with(self.context, ['fake-uuid']) - @mock.patch('nova.cells.rpcapi.CellsAPI.instance_fault_create_at_top') @mock.patch('nova.db.api.instance_fault_create') - def _test_create(self, update_cells, mock_create, cells_fault_create): + def test_create(self, mock_create): mock_create.return_value = fake_faults['fake-uuid'][1] fault = instance_fault.InstanceFault(context=self.context) fault.instance_uuid = uuids.faults_instance @@ -90,23 +89,6 @@ class _TestInstanceFault(object): 'message': 'foo', 'details': 'you screwed up', 'host': 'myhost'}) - if update_cells: - cells_fault_create.assert_called_once_with( - self.context, fake_faults['fake-uuid'][1]) - else: - self.assertFalse(cells_fault_create.called) - - def test_create_no_cells(self): - self.flags(enable=False, group='cells') - self._test_create(False) - - def test_create_api_cell(self): - self.flags(cell_type='api', enable=True, group='cells') - self._test_create(False) - - def test_create_compute_cell(self): - self.flags(cell_type='compute', enable=True, group='cells') - self._test_create(True) def test_create_already_created(self): fault = instance_fault.InstanceFault(context=self.context)