Merge "Don't update API cell on get_nwinfo"

This commit is contained in:
Jenkins 2013-05-22 11:47:52 +00:00 committed by Gerrit Code Review
commit ad5bac5a39
4 changed files with 28 additions and 21 deletions

View File

@ -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.

View File

@ -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):

View File

@ -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):

View File

@ -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)