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