Skip to content

Commit 5a9b3f3

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Remove 'instance_info_cache_update_at_top'"
2 parents 9e9c498 + e3a8188 commit 5a9b3f3

File tree

8 files changed

+10
-93
lines changed

8 files changed

+10
-93
lines changed

nova/cells/rpcapi.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from nova import cells
3232
import nova.conf
3333
from nova import exception
34-
from nova import objects
3534
from nova.objects import base as objects_base
3635
from nova import profiler
3736
from nova import rpc
@@ -248,17 +247,6 @@ def bw_usage_update_at_top(self, ctxt, uuid, mac, start_period,
248247
self.client.cast(ctxt, 'bw_usage_update_at_top',
249248
bw_update_info=bw_update_info)
250249

251-
def instance_info_cache_update_at_top(self, ctxt, instance_info_cache):
252-
"""Broadcast up that an instance's info_cache has changed."""
253-
version = '1.35'
254-
instance = objects.Instance(uuid=instance_info_cache.instance_uuid,
255-
info_cache=instance_info_cache)
256-
if not self.client.can_send_version('1.35'):
257-
instance = objects_base.obj_to_primitive(instance)
258-
version = '1.34'
259-
cctxt = self.client.prepare(version=version)
260-
cctxt.cast(ctxt, 'instance_update_at_top', instance=instance)
261-
262250
def get_cell_info_for_neighbors(self, ctxt):
263251
"""Get information about our neighbor cells from the manager."""
264252
if not CONF.cells.enable:

nova/network/base_api.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131

3232

3333
@hooks.add_hook('instance_network_info')
34-
def update_instance_cache_with_nw_info(impl, context, instance,
35-
nw_info=None, update_cells=True):
34+
def update_instance_cache_with_nw_info(impl, context, instance, nw_info=None):
3635
if instance.deleted:
3736
LOG.debug('Instance is deleted, no further info cache update',
3837
instance=instance)
@@ -52,7 +51,7 @@ def update_instance_cache_with_nw_info(impl, context, instance,
5251
# from the DB first.
5352
ic = objects.InstanceInfoCache.new(context, instance.uuid)
5453
ic.network_info = nw_info
55-
ic.save(update_cells=update_cells)
54+
ic.save()
5655
instance.info_cache = ic
5756
except Exception:
5857
with excutils.save_and_reraise_exception():
@@ -254,14 +253,8 @@ def get_instance_nw_info(self, context, instance, **kwargs):
254253
"""Returns all network info related to an instance."""
255254
with lockutils.lock('refresh_cache-%s' % instance.uuid):
256255
result = self._get_instance_nw_info(context, instance, **kwargs)
257-
# NOTE(comstud): Don't update API cell with new info_cache every
258-
# time we pull network info for an instance. The periodic healing
259-
# of info_cache causes too many cells messages. Healing the API
260-
# will happen separately.
261-
update_cells = kwargs.get('update_cells', False)
262256
update_instance_cache_with_nw_info(self, context, instance,
263-
nw_info=result,
264-
update_cells=update_cells)
257+
nw_info=result)
265258
return result
266259

267260
def _get_instance_nw_info(self, context, instance, **kwargs):

nova/network/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def _do_trigger_security_group_members_refresh_for_instance(self,
314314
None, None)
315315
ic = objects.InstanceInfoCache.new(admin_context, instance_id)
316316
ic.network_info = nw_info
317-
ic.save(update_cells=False)
317+
ic.save()
318318
except exception.InstanceInfoCacheNotFound:
319319
pass
320320
groups = instance.security_groups

nova/network/neutronv2/api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,8 +1129,7 @@ def allocate_for_instance(self, context, instance, vpn,
11291129
context, instance, networks=ordered_nets,
11301130
port_ids=ordered_port_ids,
11311131
admin_client=admin_client,
1132-
preexisting_port_ids=preexisting_port_ids,
1133-
update_cells=True)
1132+
preexisting_port_ids=preexisting_port_ids)
11341133
# Only return info about ports we processed in this run, which might
11351134
# have been pre-existing neutron ports or ones that nova created. In
11361135
# the initial allocation case (server create), this will be everything

nova/objects/instance_info_cache.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
from oslo_log import log as logging
1616

17-
from nova.cells import opts as cells_opts
18-
from nova.cells import rpcapi as cells_rpcapi
1917
from nova.db import api as db
2018
from nova import exception
2119
from nova.objects import base
@@ -71,33 +69,16 @@ def get_by_instance_uuid(cls, context, instance_uuid):
7169
instance_uuid=instance_uuid)
7270
return cls._from_db_object(context, cls(context), db_obj)
7371

74-
@staticmethod
75-
def _info_cache_cells_update(ctxt, info_cache):
76-
cell_type = cells_opts.get_cell_type()
77-
if cell_type != 'compute':
78-
return
79-
cells_api = cells_rpcapi.CellsAPI()
80-
try:
81-
cells_api.instance_info_cache_update_at_top(ctxt, info_cache)
82-
except Exception:
83-
LOG.exception("Failed to notify cells of instance info "
84-
"cache update")
85-
72+
# TODO(stephenfin): Remove 'update_cells' in version 2.0
8673
@base.remotable
8774
def save(self, update_cells=True):
8875
if 'network_info' in self.obj_what_changed():
89-
if update_cells:
90-
stale_instance = self.obj_clone()
9176
nw_info_json = self.fields['network_info'].to_primitive(
9277
self, 'network_info', self.network_info)
9378
rv = db.instance_info_cache_update(self._context,
9479
self.instance_uuid,
9580
{'network_info': nw_info_json})
9681
self._from_db_object(self._context, self, rv)
97-
if update_cells:
98-
# Send a copy of ourselves before updates are applied so
99-
# that cells can tell what changed.
100-
self._info_cache_cells_update(self._context, stale_instance)
10182
self.obj_reset_changes()
10283

10384
@base.remotable

nova/tests/unit/network/test_api.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ def fake_instance_info_cache_update(context, instance_uuid, cache):
184184
return fake_info_cache
185185

186186
def fake_update_instance_cache_with_nw_info(api, context, instance,
187-
nw_info=None,
188-
update_cells=True):
187+
nw_info=None):
189188
return
190189

191190
with test.nested(
@@ -555,8 +554,7 @@ def test_get_instance_nw_info(self, mock_update, mock_get, mock_lock):
555554
result = self.network_api.get_instance_nw_info(self.context, instance)
556555
mock_get.assert_called_once_with(self.context, instance)
557556
mock_update.assert_called_once_with(self.network_api, self.context,
558-
instance, nw_info=fake_result,
559-
update_cells=False)
557+
instance, nw_info=fake_result)
560558
self.assertEqual(fake_result, result)
561559

562560

nova/tests/unit/network/test_neutronv2.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ def _test_allocate_for_instance(self, mock_get_client, mock_get_nw,
715715
mock.ANY, self.instance, networks=nets_in_requested_net_order,
716716
port_ids=ports_in_requested_net_order,
717717
admin_client=mocked_client,
718-
preexisting_port_ids=preexisting_port_ids, update_cells=True)
718+
preexisting_port_ids=preexisting_port_ids)
719719

720720
return nw_info, mocked_client
721721

@@ -3573,8 +3573,7 @@ def test_get_instance_nw_info(self, mock_update, mock_get, mock_lock):
35733573
result = self.api.get_instance_nw_info(self.context, instance)
35743574
mock_get.assert_called_once_with(self.context, instance)
35753575
mock_update.assert_called_once_with(self.api, self.context, instance,
3576-
nw_info=fake_result,
3577-
update_cells=False)
3576+
nw_info=fake_result)
35783577
self.assertEqual(fake_result, result)
35793578

35803579
def _test_validate_networks_fixed_ip_no_dup(self, nets, requested_networks,

nova/tests/unit/objects/test_instance_info_cache.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
from oslo_utils.fixture import uuidsentinel as uuids
1919
from oslo_utils import timeutils
2020

21-
from nova.cells import opts as cells_opts
22-
from nova.cells import rpcapi as cells_rpcapi
2321
from nova.db import api as db
2422
from nova import exception
2523
from nova.network import model as network_model
@@ -65,45 +63,6 @@ def test_new(self):
6563
self.assertEqual(uuids.info_instance, obj.instance_uuid)
6664
self.assertIsNone(obj.network_info)
6765

68-
@mock.patch.object(cells_opts, 'get_cell_type')
69-
@mock.patch.object(cells_rpcapi, 'CellsAPI')
70-
@mock.patch.object(db, 'instance_info_cache_update')
71-
def _save_helper(self, cell_type, update_cells, mock_update,
72-
mock_rpc, mock_get_type):
73-
obj = instance_info_cache.InstanceInfoCache()
74-
cells_api = cells_rpcapi.CellsAPI()
75-
76-
nwinfo = network_model.NetworkInfo.hydrate([{'address': 'foo'}])
77-
new_info_cache = fake_info_cache.copy()
78-
new_info_cache['network_info'] = nwinfo.json()
79-
mock_update.return_value = new_info_cache
80-
with mock.patch.object(cells_api,
81-
'instance_info_cache_update_at_top'):
82-
if update_cells:
83-
mock_get_type.return_vaule = cell_type
84-
if cell_type == 'compute':
85-
mock_rpc.return_value = cells_api
86-
cells_api.instance_info_cache_update_at_top(
87-
self.context, 'foo')
88-
mock_rpc.assert_called_once_with()
89-
obj._context = self.context
90-
obj.instance_uuid = uuids.info_instance
91-
obj.network_info = nwinfo
92-
obj.save(update_cells=update_cells)
93-
mock_update.assert_called_once_with(self.context, obj.instance_uuid,
94-
{'network_info': nwinfo.json()})
95-
if update_cells:
96-
mock_get_type.assert_called_once()
97-
98-
def test_save_with_update_cells_and_compute_cell(self):
99-
self._save_helper('compute', True)
100-
101-
def test_save_with_update_cells_and_non_compute_cell(self):
102-
self._save_helper(None, True)
103-
104-
def test_save_without_update_cells(self):
105-
self._save_helper(None, False)
106-
10766
@mock.patch.object(db, 'instance_info_cache_update')
10867
def test_save_updates_self(self, mock_update):
10968
fake_updated_at = datetime.datetime(2015, 1, 1)

0 commit comments

Comments
 (0)