summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/cells/messaging.py4
-rw-r--r--nova/db/api.py13
-rw-r--r--nova/network/api.py26
-rw-r--r--nova/tests/cells/test_cells_messaging.py6
4 files changed, 28 insertions, 21 deletions
diff --git a/nova/cells/messaging.py b/nova/cells/messaging.py
index 60f11ad12..1ea68d29f 100644
--- a/nova/cells/messaging.py
+++ b/nova/cells/messaging.py
@@ -847,8 +847,8 @@ class _BroadcastMessageMethods(_BaseMessageMethods):
self.db.instance_create(message.ctxt, instance)
if info_cache:
try:
- self.db.instance_info_cache_update(message.ctxt,
- instance_uuid, info_cache, update_cells=False)
+ self.db.instance_info_cache_update(
+ message.ctxt, instance_uuid, info_cache)
except exception.InstanceInfoCacheNotFound:
# Can happen if we try to update a deleted instance's
# network information.
diff --git a/nova/db/api.py b/nova/db/api.py
index 322247311..677ed771b 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -719,22 +719,13 @@ def instance_info_cache_get(context, instance_uuid):
return IMPL.instance_info_cache_get(context, instance_uuid)
-def instance_info_cache_update(context, instance_uuid, values,
- update_cells=True):
+def instance_info_cache_update(context, instance_uuid, values):
"""Update an instance info cache record in the table.
:param instance_uuid: = uuid of info cache's instance
:param values: = dict containing column values to update
"""
- rv = IMPL.instance_info_cache_update(context, instance_uuid, values)
- if update_cells:
- try:
- cells_rpcapi.CellsAPI().instance_info_cache_update_at_top(
- context, rv)
- except Exception:
- LOG.exception(_("Failed to notify cells of instance info "
- "cache update"))
- return rv
+ return IMPL.instance_info_cache_update(context, instance_uuid, values)
def instance_info_cache_delete(context, instance_uuid):
diff --git a/nova/network/api.py b/nova/network/api.py
index 26bf03446..1654bb32c 100644
--- a/nova/network/api.py
+++ b/nova/network/api.py
@@ -21,6 +21,7 @@
import functools
import inspect
+from nova.cells import rpcapi as cells_rpcapi
from nova.compute import flavors
from nova.db import base
from nova import exception
@@ -64,7 +65,8 @@ def refresh_cache(f):
def update_instance_cache_with_nw_info(api, context, instance,
- nw_info=None, conductor_api=None):
+ nw_info=None, conductor_api=None,
+ update_cells=True):
try:
if not isinstance(nw_info, network_model.NetworkInfo):
nw_info = None
@@ -73,9 +75,20 @@ def update_instance_cache_with_nw_info(api, context, instance,
# update cache
cache = {'network_info': nw_info.json()}
if conductor_api:
- conductor_api.instance_info_cache_update(context, instance, cache)
+ rv = conductor_api.instance_info_cache_update(context,
+ instance,
+ cache)
else:
- api.db.instance_info_cache_update(context, instance['uuid'], cache)
+ rv = api.db.instance_info_cache_update(context,
+ instance['uuid'],
+ cache)
+ if update_cells:
+ cells_api = cells_rpcapi.CellsAPI()
+ try:
+ cells_api.instance_info_cache_update_at_top(context, rv)
+ except Exception:
+ LOG.exception(_("Failed to notify cells of instance info "
+ "cache update"))
except Exception:
LOG.exception(_('Failed storing info cache'), instance=instance)
@@ -366,8 +379,13 @@ class API(base.Base):
def get_instance_nw_info(self, context, instance, conductor_api=None):
"""Returns all network info related to an instance."""
result = self._get_instance_nw_info(context, instance)
+ # NOTE(comstud): Don't update API cell with new info_cache every
+ # time we pull network info for an instance. The periodic healing
+ # of info_cache causes too many cells messages. Healing the API
+ # will happen separately.
update_instance_cache_with_nw_info(self, context, instance,
- result, conductor_api)
+ result, conductor_api,
+ update_cells=False)
return result
def _get_instance_nw_info(self, context, instance):
diff --git a/nova/tests/cells/test_cells_messaging.py b/nova/tests/cells/test_cells_messaging.py
index 51a792975..1de39de1f 100644
--- a/nova/tests/cells/test_cells_messaging.py
+++ b/nova/tests/cells/test_cells_messaging.py
@@ -1033,8 +1033,7 @@ class CellsBroadcastMethodsTestCase(test.TestCase):
expected_instance,
update_cells=False)
self.tgt_db_inst.instance_info_cache_update(self.ctxt, 'fake_uuid',
- expected_info_cache,
- update_cells=False)
+ expected_info_cache)
self.mox.ReplayAll()
self.src_msg_runner.instance_update_at_top(self.ctxt, fake_instance)
@@ -1086,8 +1085,7 @@ class CellsBroadcastMethodsTestCase(test.TestCase):
expected_instance,
update_cells=False)
self.tgt_db_inst.instance_info_cache_update(self.ctxt, 'fake_uuid',
- expected_info_cache,
- update_cells=False)
+ expected_info_cache)
self.mox.ReplayAll()
self.src_msg_runner.instance_update_at_top(self.ctxt, fake_instance)