diff --git a/nova/cells/manager.py b/nova/cells/manager.py index c3d320687a8a..6efa4d27f609 100644 --- a/nova/cells/manager.py +++ b/nova/cells/manager.py @@ -225,10 +225,6 @@ class CellsManager(manager.Manager): self.msg_runner.instance_delete_everywhere(ctxt, instance, delete_type) - 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) - def sync_instances(self, ctxt, project_id, updated_since, deleted): """Force a sync of all instances, potentially by project_id, and potentially since a certain date/time. diff --git a/nova/cells/messaging.py b/nova/cells/messaging.py index cc0d92ab09f9..710393a201ad 100644 --- a/nova/cells/messaging.py +++ b/nova/cells/messaging.py @@ -973,12 +973,6 @@ class _BroadcastMessageMethods(_BaseMessageMethods): else: self.compute_api.delete(message.ctxt, instance) - 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(): - return - self.db.bw_usage_update(message.ctxt, **bw_update_info) - def _sync_instance(self, ctxt, instance): pass @@ -1254,13 +1248,6 @@ class MessageRunner(object): 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', - dict(bw_update_info=bw_update_info), - 'up', run_locally=False) - message.process() - def sync_instances(self, ctxt, project_id, updated_since, deleted): """Force a sync of all instances, potentially by project_id, and potentially since a certain date/time. diff --git a/nova/cells/rpcapi.py b/nova/cells/rpcapi.py index 46b455c003b5..88daa4894cb1 100644 --- a/nova/cells/rpcapi.py +++ b/nova/cells/rpcapi.py @@ -215,20 +215,6 @@ class CellsAPI(object): cctxt.cast(ctxt, 'instance_delete_everywhere', instance=instance, delete_type=delete_type) - 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.""" - bw_update_info = {'uuid': uuid, - 'mac': mac, - 'start_period': start_period, - 'bw_in': bw_in, - 'bw_out': bw_out, - 'last_ctr_in': last_ctr_in, - 'last_ctr_out': last_ctr_out, - 'last_refreshed': last_refreshed} - self.client.cast(ctxt, 'bw_usage_update_at_top', - bw_update_info=bw_update_info) - def get_cell_info_for_neighbors(self, ctxt): """Get information about our neighbor cells from the manager.""" if not CONF.cells.enable: diff --git a/nova/compute/manager.py b/nova/compute/manager.py index c69878c659e6..9ef1346631ba 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -7569,14 +7569,6 @@ class ComputeManager(manager.Manager): CONF.bandwidth_poll_interval): self._last_bw_usage_poll = curr_time LOG.info("Updating bandwidth usage cache") - cells_update_interval = CONF.cells.bandwidth_update_interval - if (cells_update_interval > 0 and - curr_time - self._last_bw_usage_cell_update > - cells_update_interval): - self._last_bw_usage_cell_update = curr_time - update_cells = True - else: - update_cells = False instances = objects.InstanceList.get_by_host(context, self.host, @@ -7642,8 +7634,7 @@ class ComputeManager(manager.Manager): bw_ctr['bw_in'], bw_ctr['bw_out'], start_period=start_time, - last_refreshed=refreshed, - update_cells=update_cells) + last_refreshed=refreshed) def _get_host_volume_bdms(self, context, use_slave=False): """Return all block device mappings on a compute host.""" diff --git a/nova/db/api.py b/nova/db/api.py index cce1d2a00d7f..9ad4497094c1 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -30,7 +30,6 @@ these objects be simple dictionaries. from oslo_db import concurrency from oslo_log import log as logging -from nova.cells import rpcapi as cells_rpcapi import nova.conf from nova.db import constants @@ -1625,20 +1624,12 @@ def bw_usage_get_by_uuids(context, uuids, start_period): def bw_usage_update(context, uuid, mac, start_period, bw_in, bw_out, - last_ctr_in, last_ctr_out, last_refreshed=None, - update_cells=True): + last_ctr_in, last_ctr_out, last_refreshed=None): """Update cached bandwidth usage for an instance's network based on mac address. Creates new record if needed. """ rv = IMPL.bw_usage_update(context, uuid, mac, start_period, bw_in, bw_out, last_ctr_in, last_ctr_out, last_refreshed=last_refreshed) - if update_cells: - try: - cells_rpcapi.CellsAPI().bw_usage_update_at_top(context, - uuid, mac, start_period, bw_in, bw_out, - last_ctr_in, last_ctr_out, last_refreshed) - except Exception: - LOG.exception("Failed to notify cells of bw_usage update") return rv diff --git a/nova/objects/bandwidth_usage.py b/nova/objects/bandwidth_usage.py index 753309be36f1..809e3c63af45 100644 --- a/nova/objects/bandwidth_usage.py +++ b/nova/objects/bandwidth_usage.py @@ -60,6 +60,7 @@ class BandwidthUsage(base.NovaPersistentObject, base.NovaObject): if db_bw_usage: return cls._from_db_object(context, cls(), db_bw_usage) + # TODO(stephenfin): Remove 'update_cells' in version 2.0 of the object @base.serialize_args @base.remotable def create(self, uuid, mac, bw_in, bw_out, last_ctr_in, @@ -67,8 +68,7 @@ class BandwidthUsage(base.NovaPersistentObject, base.NovaObject): update_cells=True): db_bw_usage = db.bw_usage_update( self._context, uuid, mac, start_period, bw_in, bw_out, - last_ctr_in, last_ctr_out, last_refreshed=last_refreshed, - update_cells=update_cells) + last_ctr_in, last_ctr_out, last_refreshed=last_refreshed) self._from_db_object(self._context, self, db_bw_usage) diff --git a/nova/tests/unit/cells/test_cells_manager.py b/nova/tests/unit/cells/test_cells_manager.py index 47e73c66b143..e1f494008f3b 100644 --- a/nova/tests/unit/cells/test_cells_manager.py +++ b/nova/tests/unit/cells/test_cells_manager.py @@ -173,15 +173,6 @@ class CellsManagerClassTestCase(test.NoDBTestCase): self.ctxt, instance='fake-instance', delete_type='fake-type') - def test_bw_usage_update_at_top(self): - self.mox.StubOutWithMock(self.msg_runner, - 'bw_usage_update_at_top') - self.msg_runner.bw_usage_update_at_top(self.ctxt, - 'fake-bw-info') - self.mox.ReplayAll() - self.cells_manager.bw_usage_update_at_top( - self.ctxt, bw_update_info='fake-bw-info') - def test_heal_instances(self): self.flags(instance_updated_at_threshold=1000, instance_update_num_instances=2, diff --git a/nova/tests/unit/cells/test_cells_messaging.py b/nova/tests/unit/cells/test_cells_messaging.py index 507d9502cd56..bb90d49c08b0 100644 --- a/nova/tests/unit/cells/test_cells_messaging.py +++ b/nova/tests/unit/cells/test_cells_messaging.py @@ -1388,28 +1388,6 @@ class CellsBroadcastMethodsTestCase(test.NoDBTestCase): self.src_msg_runner.instance_delete_everywhere(self.ctxt, instance, 'soft') - def test_bw_usage_update_at_top(self): - fake_bw_update_info = {'uuid': 'fake_uuid', - 'mac': 'fake_mac', - 'start_period': 'fake_start_period', - 'bw_in': 'fake_bw_in', - 'bw_out': 'fake_bw_out', - 'last_ctr_in': 'fake_last_ctr_in', - 'last_ctr_out': 'fake_last_ctr_out', - 'last_refreshed': 'fake_last_refreshed'} - - # Shouldn't be called for these 2 cells - self.mox.StubOutWithMock(self.src_db_inst, 'bw_usage_update') - self.mox.StubOutWithMock(self.mid_db_inst, 'bw_usage_update') - - self.mox.StubOutWithMock(self.tgt_db_inst, 'bw_usage_update') - self.tgt_db_inst.bw_usage_update(self.ctxt, **fake_bw_update_info) - - self.mox.ReplayAll() - - self.src_msg_runner.bw_usage_update_at_top(self.ctxt, - fake_bw_update_info) - def test_sync_instances(self): # Reset this, as this is a broadcast down. self._setup_attrs(up=False) diff --git a/nova/tests/unit/cells/test_cells_rpcapi.py b/nova/tests/unit/cells/test_cells_rpcapi.py index da24ff2d1209..ccbc7d3e32ec 100644 --- a/nova/tests/unit/cells/test_cells_rpcapi.py +++ b/nova/tests/unit/cells/test_cells_rpcapi.py @@ -166,30 +166,6 @@ class CellsAPITestCase(test.NoDBTestCase): self._check_result(call_info, 'instance_delete_everywhere', expected_args, version='1.27') - 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', - 'fake_ctr_out') - update_kwargs = {'last_refreshed': 'fake_refreshed'} - - call_info = self._stub_rpc_method('cast', None) - - self.cells_rpcapi.bw_usage_update_at_top( - self.fake_context, *update_args, **update_kwargs) - - bw_update_info = {'uuid': 'fake_uuid', - 'mac': 'fake_mac', - 'start_period': 'fake_start_period', - 'bw_in': 'fake_bw_in', - 'bw_out': 'fake_bw_out', - 'last_ctr_in': 'fake_ctr_in', - 'last_ctr_out': 'fake_ctr_out', - 'last_refreshed': 'fake_refreshed'} - - expected_args = {'bw_update_info': bw_update_info} - self._check_result(call_info, 'bw_usage_update_at_top', - expected_args) - def test_get_cell_info_for_neighbors(self): call_info = self._stub_rpc_method('call', 'fake_response') result = self.cells_rpcapi.get_cell_info_for_neighbors( diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py index cf4b562dba3d..d2d5a80fbdf7 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -4549,8 +4549,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase, bw_usage_update.assert_called_once_with(self.context, uuids.instance, 'fake-mac', 0, 4, 6, 1, 2, - last_refreshed=mock.ANY, - update_cells=False) + last_refreshed=mock.ANY) def test_reverts_task_state_instance_not_found(self): # Tests that the reverts_task_state decorator in the compute manager diff --git a/nova/tests/unit/db/test_db_api.py b/nova/tests/unit/db/test_db_api.py index 50727dae374b..6ae89af3e1b9 100644 --- a/nova/tests/unit/db/test_db_api.py +++ b/nova/tests/unit/db/test_db_api.py @@ -8270,8 +8270,7 @@ class BwUsageTestCase(test.TestCase, ModelsObjectComparatorMixin): 'last_ctr_in': 54321, 'last_ctr_out': 67890, 'last_refreshed': now} - result = db.bw_usage_update( - self.ctxt, update_cells=False, **updated_bw_usage) + result = db.bw_usage_update(self.ctxt, **updated_bw_usage) # check that only bw_usage with ID 1 was updated self.assertEqual(1, result['id'])