From d1f8888843c53c1c4b95c2fd22b2b6ee97feb238 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Wed, 28 Aug 2019 13:06:33 +0000 Subject: [PATCH] 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 --- neutron/services/trunk/rpc/server.py | 5 ++--- neutron/tests/unit/services/trunk/rpc/test_server.py | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/neutron/services/trunk/rpc/server.py b/neutron/services/trunk/rpc/server.py index 39f352e0aac..daeebd8dada 100644 --- a/neutron/services/trunk/rpc/server.py +++ b/neutron/services/trunk/rpc/server.py @@ -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.TRUNK_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: diff --git a/neutron/tests/unit/services/trunk/rpc/test_server.py b/neutron/tests/unit/services/trunk/rpc/test_server.py index 63fd7fd72e0..6357635d0cf 100644 --- a/neutron/tests/unit/services/trunk/rpc/test_server.py +++ b/neutron/tests/unit/services/trunk/rpc/test_server.py @@ -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 neutron_lib.services.trunk import constants @@ -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: