From 761c967614902d78a84c7e6a56b9117a322fc5b9 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Sat, 18 Oct 2014 00:38:57 -0700 Subject: [PATCH] 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 --- neutron/plugins/ml2/drivers/helpers.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/neutron/plugins/ml2/drivers/helpers.py b/neutron/plugins/ml2/drivers/helpers.py index d3050989d..ad4500f64 100644 --- a/neutron/plugins/ml2/drivers/helpers.py +++ b/neutron/plugins/ml2/drivers/helpers.py @@ -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() -- 2.45.2