Increase number of retries in _process_trunk_subport_bindings
In patch [1] as partial fix for bug 1828375 retries mechanism
was proposed.
We noticed that sometimes in have loaded environments 3 retries
defined in [1] can be not enough.
So this patch switches to use neutron_lib.db.api.MAX_RETRIES constant
as number of retries when processing trunk subport bindings.
This MAX_RETRIES constant is set to 20 and in our cases it "fixed"
problem.
[1] https://review.opendev.org/#/c/662236/
Change-Id: I016ef3d7ccbb89b68d4a3d509162b3046a9c2f98
Related-Bug: #1828375
(cherry picked from commit d1f8888843
)
This commit is contained in:
parent
c618229f3c
commit
1199207e7d
|
@ -116,8 +116,7 @@ class TrunkSkeleton(object):
|
||||||
trunk_port = self.core_plugin.get_port(context, trunk_port_id)
|
trunk_port = self.core_plugin.get_port(context, trunk_port_id)
|
||||||
trunk_host = trunk_port.get(portbindings.HOST_ID)
|
trunk_host = trunk_port.get(portbindings.HOST_ID)
|
||||||
|
|
||||||
tries = 3
|
for try_cnt in range(db_api.MAX_RETRIES):
|
||||||
for try_cnt in range(tries):
|
|
||||||
try:
|
try:
|
||||||
# NOTE(status_police) Set the trunk in BUILD state before
|
# NOTE(status_police) Set the trunk in BUILD state before
|
||||||
# processing subport bindings. The trunk will stay in BUILD
|
# processing subport bindings. The trunk will stay in BUILD
|
||||||
|
@ -127,7 +126,7 @@ class TrunkSkeleton(object):
|
||||||
trunk.update(status=trunk_consts.BUILD_STATUS)
|
trunk.update(status=trunk_consts.BUILD_STATUS)
|
||||||
break
|
break
|
||||||
except exc.StaleDataError as e:
|
except exc.StaleDataError as e:
|
||||||
if try_cnt < tries - 1:
|
if try_cnt < db_api.MAX_RETRIES - 1:
|
||||||
LOG.debug("Got StaleDataError exception: %s", e)
|
LOG.debug("Got StaleDataError exception: %s", e)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from neutron_lib.api.definitions import portbindings
|
from neutron_lib.api.definitions import portbindings
|
||||||
|
from neutron_lib.db import api as db_api
|
||||||
from neutron_lib.plugins import directory
|
from neutron_lib.plugins import directory
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import oslo_messaging
|
import oslo_messaging
|
||||||
|
@ -186,7 +187,9 @@ class TrunkSkeletonTest(test_plugin.Ml2PluginV2TestCase):
|
||||||
test_obj.update_subport_bindings,
|
test_obj.update_subport_bindings,
|
||||||
self.context,
|
self.context,
|
||||||
subports=subports)
|
subports=subports)
|
||||||
self.assertEqual(3, mock_trunk_obj.update.call_count)
|
self.assertEqual(
|
||||||
|
db_api.MAX_RETRIES,
|
||||||
|
mock_trunk_obj.update.call_count)
|
||||||
|
|
||||||
def test_udate_subport_bindings_noretryerror(self):
|
def test_udate_subport_bindings_noretryerror(self):
|
||||||
with self.port() as _parent_port:
|
with self.port() as _parent_port:
|
||||||
|
|
Loading…
Reference in New Issue