]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Rename constant to a more appropriate name
authorKevin Benton <blak111@gmail.com>
Sat, 18 Oct 2014 07:38:57 +0000 (00:38 -0700)
committerKevin Benton <kevinbenton@buttewifi.com>
Wed, 29 Oct 2014 07:11:43 +0000 (07:11 +0000)
The DB_MAX_RETRIES implies that a query will be
retried that many times. 'retry' means it happened
once before. In the current code, if DB_MAX_RETRIES
is set to 1, the query won't be retried at all.
If it's set to 0, the query won't even be run.

This constant should actually be called DB_MAX_ATTEMPTS
to indicate that the variable includes the first try.

Change-Id: I13f088ffa38c40db7fd297173e892b4ad5c7fadd

neutron/plugins/ml2/drivers/helpers.py

index d3050989ddd71338e52336aebee2a36e6d8a9879..ad4500f646dbf1a521d5176111167841dc11c8f3 100644 (file)
@@ -20,8 +20,8 @@ from neutron.openstack.common import log
 from neutron.plugins.ml2 import driver_api as api
 
 
-# Number of retries to find a valid segment candidate and allocate it
-DB_MAX_RETRIES = 10
+# Number of attempts to find a valid segment candidate and allocate it
+DB_MAX_ATTEMPTS = 10
 
 
 LOG = log.getLogger(__name__)
@@ -107,8 +107,8 @@ class TypeDriverHelper(api.TypeDriver):
                       filter_by(allocated=False, **filters))
 
             # Selected segment can be allocated before update by someone else,
-            # We retry until update success or DB_MAX_RETRIES retries
-            for attempt in range(1, DB_MAX_RETRIES + 1):
+            # We retry until update success or DB_MAX_ATTEMPTS attempts
+            for attempt in range(1, DB_MAX_ATTEMPTS + 1):
                 alloc = select.first()
 
                 if not alloc:
@@ -139,5 +139,5 @@ class TypeDriverHelper(api.TypeDriver):
 
         LOG.warning(_("Allocate %(type)s segment from pool failed "
                       "after %(number)s failed attempts"),
-                    {"type": network_type, "number": DB_MAX_RETRIES})
+                    {"type": network_type, "number": DB_MAX_ATTEMPTS})
         raise exc.NoNetworkFoundInMaximumAllowedAttempts()