Log object lazy-loads

This is a trivial change that will be extremely helpful in tracking
down spurious lazy-loads and performance issues in the field. Simply
log to DEBUG any time we do a lazy-load of something. In practice,
this should be relatively rare.

Change-Id: I5e7bc058ba5ad17536a361367a0def5c4953643e
This commit is contained in:
Dan Smith 2013-09-20 11:22:01 -07:00
parent 5429048045
commit be50c33ee6
3 changed files with 16 additions and 0 deletions

View File

@ -473,6 +473,11 @@ class Instance(base.NovaPersistentObject, base.NovaObject):
action='obj_load_attr',
reason='attribute %s not lazy-loadable' % attrname)
LOG.debug(_("Lazy-loading `%(attr)s' on %(name) uuid %(uuid)s"),
{'attr': attrname,
'name': self.obj_name(),
'uuid': self.uuid,
})
# FIXME(comstud): This should be optimized to only load the attr.
instance = self.__class__.get_by_uuid(self._context,
uuid=self.uuid,

View File

@ -18,6 +18,11 @@ from nova import exception
from nova.objects import base
from nova.objects import compute_node
from nova.objects import utils
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
LOG = logging.getLogger(__name__)
class Service(base.NovaPersistentObject, base.NovaObject):
@ -65,6 +70,11 @@ class Service(base.NovaPersistentObject, base.NovaObject):
return service
def obj_load_attr(self, attrname):
LOG.debug(_("Lazy-loading `%(attr)s' on %(name)s id %(id)s"),
{'attr': attrname,
'name': self.obj_name(),
'id': self.id,
})
if attrname != 'compute_node':
raise exception.ObjectActionError(
action='obj_load_attr',

View File

@ -171,6 +171,7 @@ class _TestInstanceObject(object):
def test_load_invalid(self):
inst = instance.Instance()
inst.uuid = 'fake-uuid'
self.assertRaises(exception.ObjectActionError,
inst.obj_load_attr, 'foo')