Don't log message for keystone ID query when supressing exceptions

Barbican repo method find_by_keystone_id will check the DB for a
tenant ID.  It also takes a flag, supress_exception, so that a
"tenant not found" type of error won't result in an exception
being percolated to its caller.

When the query is done for a tenant that has never been used
it will raise a NoResultFound which gets caught and only
percolated if the supress_exception flag is false.

Previous to this change, we would log this NoResultFound which
in many cases is expected behaviour (hence the supress_exception
flag).  This could be confusing for someone looking at barbican
logs (or an automated log crawler) since this exception is actually
expected behaviour.

This change moves the logging of the exception so that it only
happens if the supress_exception flag is false.  This keeps these
expected exceptions out of the logs.

Change-Id: I864ab7db19efb2230f43c9287103b97fa7b16beb
Closes-Bug: 1347205
This commit is contained in:
Steve Heyman
2014-07-23 11:40:32 -05:00
parent 7fffe9540c
commit ed5eab5f53

View File

@@ -507,9 +507,9 @@ class TenantRepo(BaseRepo):
entity = query.one()
except sa_orm.exc.NoResultFound:
LOG.exception("Problem getting Tenant {0}".format(keystone_id))
entity = None
if not suppress_exception:
LOG.exception("Problem getting Tenant {0}".format(keystone_id))
raise exception.NotFound("No %s found with keystone-ID %s"
% (self._do_entity_name(),
keystone_id))