Don't update API cell on get_nwinfo
Every call to get_instance_nw_info() updates an instance's info_cache. The purpose of this is to make sure we're constantly healing the info_cache table. However, this causes a lot of unneeded updates traveling up to the API cell. Cells has its own periodic task that heals all instance data. Fixes bug 1180304 Change-Id: I07774712a6358999fd1fdd0f5a90c6f05e3d8d6e
This commit is contained in:
parent
c39687edb9
commit
4251bba3bd
@ -847,8 +847,8 @@ class _BroadcastMessageMethods(_BaseMessageMethods):
|
|||||||
self.db.instance_create(message.ctxt, instance)
|
self.db.instance_create(message.ctxt, instance)
|
||||||
if info_cache:
|
if info_cache:
|
||||||
try:
|
try:
|
||||||
self.db.instance_info_cache_update(message.ctxt,
|
self.db.instance_info_cache_update(
|
||||||
instance_uuid, info_cache, update_cells=False)
|
message.ctxt, instance_uuid, info_cache)
|
||||||
except exception.InstanceInfoCacheNotFound:
|
except exception.InstanceInfoCacheNotFound:
|
||||||
# Can happen if we try to update a deleted instance's
|
# Can happen if we try to update a deleted instance's
|
||||||
# network information.
|
# network information.
|
||||||
|
@ -719,22 +719,13 @@ def instance_info_cache_get(context, instance_uuid):
|
|||||||
return IMPL.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,
|
def instance_info_cache_update(context, instance_uuid, values):
|
||||||
update_cells=True):
|
|
||||||
"""Update an instance info cache record in the table.
|
"""Update an instance info cache record in the table.
|
||||||
|
|
||||||
:param instance_uuid: = uuid of info cache's instance
|
:param instance_uuid: = uuid of info cache's instance
|
||||||
:param values: = dict containing column values to update
|
:param values: = dict containing column values to update
|
||||||
"""
|
"""
|
||||||
rv = IMPL.instance_info_cache_update(context, instance_uuid, values)
|
return 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
|
|
||||||
|
|
||||||
|
|
||||||
def instance_info_cache_delete(context, instance_uuid):
|
def instance_info_cache_delete(context, instance_uuid):
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
|
from nova.cells import rpcapi as cells_rpcapi
|
||||||
from nova.compute import flavors
|
from nova.compute import flavors
|
||||||
from nova.db import base
|
from nova.db import base
|
||||||
from nova import exception
|
from nova import exception
|
||||||
@ -64,7 +65,8 @@ def refresh_cache(f):
|
|||||||
|
|
||||||
|
|
||||||
def update_instance_cache_with_nw_info(api, context, instance,
|
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:
|
try:
|
||||||
if not isinstance(nw_info, network_model.NetworkInfo):
|
if not isinstance(nw_info, network_model.NetworkInfo):
|
||||||
nw_info = None
|
nw_info = None
|
||||||
@ -73,9 +75,20 @@ def update_instance_cache_with_nw_info(api, context, instance,
|
|||||||
# update cache
|
# update cache
|
||||||
cache = {'network_info': nw_info.json()}
|
cache = {'network_info': nw_info.json()}
|
||||||
if conductor_api:
|
if conductor_api:
|
||||||
conductor_api.instance_info_cache_update(context, instance, cache)
|
rv = conductor_api.instance_info_cache_update(context,
|
||||||
|
instance,
|
||||||
|
cache)
|
||||||
else:
|
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:
|
except Exception:
|
||||||
LOG.exception(_('Failed storing info cache'), instance=instance)
|
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):
|
def get_instance_nw_info(self, context, instance, conductor_api=None):
|
||||||
"""Returns all network info related to an instance."""
|
"""Returns all network info related to an instance."""
|
||||||
result = self._get_instance_nw_info(context, 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,
|
update_instance_cache_with_nw_info(self, context, instance,
|
||||||
result, conductor_api)
|
result, conductor_api,
|
||||||
|
update_cells=False)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _get_instance_nw_info(self, context, instance):
|
def _get_instance_nw_info(self, context, instance):
|
||||||
|
@ -1033,8 +1033,7 @@ class CellsBroadcastMethodsTestCase(test.TestCase):
|
|||||||
expected_instance,
|
expected_instance,
|
||||||
update_cells=False)
|
update_cells=False)
|
||||||
self.tgt_db_inst.instance_info_cache_update(self.ctxt, 'fake_uuid',
|
self.tgt_db_inst.instance_info_cache_update(self.ctxt, 'fake_uuid',
|
||||||
expected_info_cache,
|
expected_info_cache)
|
||||||
update_cells=False)
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
self.src_msg_runner.instance_update_at_top(self.ctxt, fake_instance)
|
self.src_msg_runner.instance_update_at_top(self.ctxt, fake_instance)
|
||||||
@ -1086,8 +1085,7 @@ class CellsBroadcastMethodsTestCase(test.TestCase):
|
|||||||
expected_instance,
|
expected_instance,
|
||||||
update_cells=False)
|
update_cells=False)
|
||||||
self.tgt_db_inst.instance_info_cache_update(self.ctxt, 'fake_uuid',
|
self.tgt_db_inst.instance_info_cache_update(self.ctxt, 'fake_uuid',
|
||||||
expected_info_cache,
|
expected_info_cache)
|
||||||
update_cells=False)
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
self.src_msg_runner.instance_update_at_top(self.ctxt, fake_instance)
|
self.src_msg_runner.instance_update_at_top(self.ctxt, fake_instance)
|
||||||
|
Loading…
Reference in New Issue
Block a user