From 2f649b321c7273d60b23d2af0ea863a0a00c6367 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Mon, 5 Oct 2015 13:19:02 -0700 Subject: [PATCH] RetryDecorator should not log warnings/errors for expected exceptions The RetryDecorator is constructed with a list of expected exceptions and if the function being retried raises an exception in that list, it is currently logging a warning (with traceback). If there is a timeout, an error is also logged. This is bad practice because only the caller of the method being retried has context as to what's going on and knows what level things should be logged at (and if tracebacks should be logged at all). This change drops the warning and error logging to debug level. We let the caller handle the final re-raised exception and handle logging it at the appropriate level and with the appropriate context for the message to make sense to someone reading the logs rather than the somewhat obscure messages logged within RetryDecorator. Closes-Bug: #1503017 Change-Id: I07344aae977aca540a0555eef8d35b07bb969cbb --- oslo_service/loopingcall.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/oslo_service/loopingcall.py b/oslo_service/loopingcall.py index 86fb4ace..cf3506a8 100644 --- a/oslo_service/loopingcall.py +++ b/oslo_service/loopingcall.py @@ -247,18 +247,17 @@ class RetryDecorator(object): result = f(*args, **kwargs) except self._exceptions: with excutils.save_and_reraise_exception() as ctxt: - LOG.warn(_LW("Exception which is in the suggested list of " - "exceptions occurred while invoking function:" - " %s."), - func_name, - exc_info=True) + LOG.debug("Exception which is in the suggested list of " + "exceptions occurred while invoking function:" + " %s.", + func_name) if (self._max_retry_count != -1 and self._retry_count >= self._max_retry_count): - LOG.error(_LE("Cannot retry %(func_name)s upon " - "suggested exception " - "since retry count (%(retry_count)d) " - "reached max retry count " - "(%(max_retry_count)d)."), + LOG.debug("Cannot retry %(func_name)s upon " + "suggested exception " + "since retry count (%(retry_count)d) " + "reached max retry count " + "(%(max_retry_count)d).", {'retry_count': self._retry_count, 'max_retry_count': self._max_retry_count, 'func_name': func_name})