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:
Slawek Kaplonski 2019-08-28 13:06:33 +00:00
parent 5555359776
commit c09e829580
2 changed files with 6 additions and 4 deletions

View File

@ -116,8 +116,7 @@ class TrunkSkeleton(object):
trunk_port = self.core_plugin.get_port(context, trunk_port_id)
trunk_host = trunk_port.get(portbindings.HOST_ID)
tries = 3
for try_cnt in range(tries):
for try_cnt in range(db_api.MAX_RETRIES):
try:
# NOTE(status_police) Set the trunk in BUILD state before
# processing subport bindings. The trunk will stay in BUILD
@ -127,7 +126,7 @@ class TrunkSkeleton(object):
trunk.update(status=trunk_consts.BUILD_STATUS)
break
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)
continue
else:

View File

@ -13,6 +13,7 @@
import mock
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 import rpc as n_rpc
from sqlalchemy.orm import exc
@ -184,7 +185,9 @@ class TrunkSkeletonTest(test_plugin.Ml2PluginV2TestCase):
test_obj.update_subport_bindings,
self.context,
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):
with self.port() as _parent_port: