Move retries out of ML2 plugin
There are several DB retry decorators in the ML2 plugin.
We want to keep them in the API layer as much possible so
this patch removes all but 1 and adds the retryrequest catch
to the API-level decorator.
The remaining one is the update_port_status which is an internal
RPC called method so it's not clear if there is a benefit to
moving it to the ml2 rpc file.
Change-Id: Ifffd424b693f57b5dd3de4dc625b50acc23abe0f
Closes-Bug: #1505908
(cherry picked from commit f6df2e704b
)
This commit is contained in:
parent
68e88eb28a
commit
47f7e73567
|
@ -32,6 +32,7 @@ MAX_RETRIES = 10
|
|||
is_deadlock = lambda e: isinstance(e, db_exc.DBDeadlock)
|
||||
retry_db_errors = oslo_db_api.wrap_db_retry(
|
||||
max_retries=MAX_RETRIES,
|
||||
retry_on_request=True,
|
||||
exception_checker=is_deadlock
|
||||
)
|
||||
|
||||
|
|
|
@ -567,8 +567,6 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
{'res': resource,
|
||||
'id': obj['result']['id']})
|
||||
|
||||
@oslo_db_api.wrap_db_retry(max_retries=db_api.MAX_RETRIES,
|
||||
retry_on_request=True)
|
||||
def _create_bulk_ml2(self, resource, context, request_items):
|
||||
objects = []
|
||||
collection = "%ss" % resource
|
||||
|
@ -632,14 +630,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
|
||||
return result, mech_context
|
||||
|
||||
@oslo_db_api.wrap_db_retry(max_retries=db_api.MAX_RETRIES,
|
||||
retry_on_request=True)
|
||||
def _create_network_with_retries(self, context, network):
|
||||
return self._create_network_db(context, network)
|
||||
|
||||
def create_network(self, context, network):
|
||||
result, mech_context = self._create_network_with_retries(context,
|
||||
network)
|
||||
result, mech_context = self._create_network_db(context, network)
|
||||
try:
|
||||
self.mechanism_manager.create_network_postcommit(mech_context)
|
||||
except ml2_exc.MechanismDriverError:
|
||||
|
@ -871,8 +863,6 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
self.mechanism_manager.update_subnet_postcommit(mech_context)
|
||||
return updated_subnet
|
||||
|
||||
@oslo_db_api.wrap_db_retry(max_retries=db_api.MAX_RETRIES,
|
||||
retry_on_request=True)
|
||||
def delete_subnet(self, context, id):
|
||||
# REVISIT(rkukura) The super(Ml2Plugin, self).delete_subnet()
|
||||
# function is not used because it deallocates the subnet's addresses
|
||||
|
@ -1028,8 +1018,6 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
|
||||
return result, mech_context
|
||||
|
||||
@oslo_db_api.wrap_db_retry(max_retries=db_api.MAX_RETRIES,
|
||||
retry_on_request=True)
|
||||
def create_port(self, context, port):
|
||||
attrs = port[attributes.PORT]
|
||||
result, mech_context = self._create_port_db(context, port)
|
||||
|
|
|
@ -312,15 +312,13 @@ class TestMl2NetworksV2(test_plugin.TestNetworksV2,
|
|||
|
||||
def test_create_network_segment_allocation_fails(self):
|
||||
plugin = manager.NeutronManager.get_plugin()
|
||||
with mock.patch.object(plugin.type_manager, 'create_network_segments',
|
||||
side_effect=db_exc.RetryRequest(ValueError())) as f:
|
||||
self.assertRaises(ValueError,
|
||||
plugin.create_network,
|
||||
context.get_admin_context(),
|
||||
{'network': {'tenant_id': 'sometenant',
|
||||
'name': 'dummy',
|
||||
'admin_state_up': True,
|
||||
'shared': False}})
|
||||
with mock.patch.object(
|
||||
plugin.type_manager, 'create_network_segments',
|
||||
side_effect=db_exc.RetryRequest(ValueError())
|
||||
) as f:
|
||||
data = {'network': {'tenant_id': 'sometenant', 'name': 'dummy',
|
||||
'admin_state_up': True, 'shared': False}}
|
||||
self.new_create_request('networks', data).get_response(self.api)
|
||||
self.assertEqual(db_api.MAX_RETRIES + 1, f.call_count)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue