Rename constant to a more appropriate name

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
This commit is contained in:
Kevin Benton 2014-10-18 00:38:57 -07:00 committed by Kevin Benton
parent fd37ce7d94
commit 761c967614
1 changed files with 5 additions and 5 deletions

View 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()