]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Don't log deadlock or retry exceptions in L3 DB
authorKevin Benton <blak111@gmail.com>
Fri, 4 Sep 2015 00:43:37 +0000 (17:43 -0700)
committerKevin Benton <blak111@gmail.com>
Fri, 4 Sep 2015 01:15:01 +0000 (18:15 -0700)
We don't want to log exceptions in the l3 DB that will be retried
by the DB retry decorator because it will look like a failure in
the log when it actually ends up being retried.

Change-Id: I024fc2db9022809194178c227d994bc6ed33c78b
Closes-Bug: #1494886

neutron/db/l3_db.py

index 07173791e16deb8eaab313f15bc103f9072fa1de..60ab661b9af08ca5fbc7410f0eb2fc2f886ea45d 100644 (file)
@@ -13,6 +13,7 @@
 #    under the License.
 
 import netaddr
+from oslo_db import exception as db_exc
 from oslo_log import log as logging
 from oslo_utils import uuidutils
 import sqlalchemy as sa
@@ -179,10 +180,13 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase):
             if gw_info:
                 self._update_router_gw_info(context, router_db['id'],
                                             gw_info, router=router_db)
-        except Exception:
+        except Exception as e:
             with excutils.save_and_reraise_exception():
-                LOG.exception(_LE("An exception occurred while creating "
-                                  "the router: %s"), router)
+                # NOTE(kevinbenton): db errors will be retried by the decorator
+                # at the API layer so it's not a complete failure scenario.
+                if not isinstance(e, (db_exc.DBDeadlock, db_exc.RetryRequest)):
+                    LOG.exception(_LE("An exception occurred while creating "
+                                      "the router: %s"), router)
                 self.delete_router(context, router_db.id)
 
         return self._make_router_dict(router_db)