ovo_rpc: Avoid flooding logs with semantic violation warning

Still log them, but not repeatedly.
Also, lower the level from error to warning.

The message has been there long enough. (since [1])
Relevant parties should have already known if their service
plugin needs to be refactored or not.  It's no longer
desirable to keep the warning that loud.

[1] I5efc625c5e8565693e795d70e0f85810552d38cd

Closes-Bug: #1696668
Change-Id: I4f1f399ac8e1c9acec9c7bce2f57c053c98e3031
This commit is contained in:
YAMAMOTO Takashi 2017-07-10 14:11:24 +09:00
parent 3d4aee57db
commit 5b78a81e2d
1 changed files with 11 additions and 10 deletions

View File

@ -21,7 +21,6 @@ from neutron_lib import context as n_ctx
from oslo_concurrency import lockutils
from oslo_log import log as logging
from neutron._i18n import _LE
from neutron.api.rpc.callbacks import events as rpc_events
from neutron.api.rpc.handlers import resources_rpc
from neutron.db import api as db_api
@ -40,6 +39,7 @@ class _ObjectChangeHandler(object):
self._resource_push_api = resource_push_api
self._resources_to_push = {}
self._worker_pool = eventlet.GreenPool()
self._semantic_warned = False
for event in (events.AFTER_CREATE, events.AFTER_UPDATE,
events.AFTER_DELETE):
registry.subscribe(self.handle_event, resource, event)
@ -48,8 +48,7 @@ class _ObjectChangeHandler(object):
"""Waits for all outstanding events to be dispatched."""
self._worker_pool.waitall()
@staticmethod
def _is_session_semantic_violated(context, resource, event):
def _is_session_semantic_violated(self, context, resource, event):
"""Return True and print an ugly error on transaction violation.
This code is to print ugly errors when AFTER_CREATE/UPDATE
@ -58,13 +57,15 @@ class _ObjectChangeHandler(object):
"""
if not context.session.is_active:
return False
if not self._semantic_warned:
stack = traceback.extract_stack()
stack = "".join(traceback.format_list(stack))
LOG.error(_LE("This handler is supposed to handle AFTER "
LOG.warning("This handler is supposed to handle AFTER "
"events, as in 'AFTER it's committed', "
"not BEFORE. Offending resource event: "
"%(r)s, %(e)s. Location:\n%(l)s"),
"%(r)s, %(e)s. Location:\n%(l)s",
{'r': resource, 'e': event, 'l': stack})
self._semantic_warned = True
return True
def handle_event(self, resource, event, trigger,