Browse Source

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)
changes/97/679197/1
Slawek Kaplonski 3 weeks ago
parent
commit
c09e829580

+ 2
- 3
neutron/services/trunk/rpc/server.py View File

@@ -116,8 +116,7 @@ class TrunkSkeleton(object):
116 116
         trunk_port = self.core_plugin.get_port(context, trunk_port_id)
117 117
         trunk_host = trunk_port.get(portbindings.HOST_ID)
118 118
 
119
-        tries = 3
120
-        for try_cnt in range(tries):
119
+        for try_cnt in range(db_api.MAX_RETRIES):
121 120
             try:
122 121
                 # NOTE(status_police) Set the trunk in BUILD state before
123 122
                 # processing subport bindings. The trunk will stay in BUILD
@@ -127,7 +126,7 @@ class TrunkSkeleton(object):
127 126
                 trunk.update(status=trunk_consts.BUILD_STATUS)
128 127
                 break
129 128
             except exc.StaleDataError as e:
130
-                if try_cnt < tries - 1:
129
+                if try_cnt < db_api.MAX_RETRIES - 1:
131 130
                     LOG.debug("Got StaleDataError exception: %s", e)
132 131
                     continue
133 132
                 else:

+ 4
- 1
neutron/tests/unit/services/trunk/rpc/test_server.py View File

@@ -13,6 +13,7 @@
13 13
 
14 14
 import mock
15 15
 from neutron_lib.api.definitions import portbindings
16
+from neutron_lib.db import api as db_api
16 17
 from neutron_lib.plugins import directory
17 18
 from neutron_lib import rpc as n_rpc
18 19
 from sqlalchemy.orm import exc
@@ -184,7 +185,9 @@ class TrunkSkeletonTest(test_plugin.Ml2PluginV2TestCase):
184 185
                 test_obj.update_subport_bindings,
185 186
                 self.context,
186 187
                 subports=subports)
187
-            self.assertEqual(3, mock_trunk_obj.update.call_count)
188
+            self.assertEqual(
189
+                db_api.MAX_RETRIES,
190
+                mock_trunk_obj.update.call_count)
188 191
 
189 192
     def test_udate_subport_bindings_noretryerror(self):
190 193
         with self.port() as _parent_port:

Loading…
Cancel
Save