NSXv: retry call to create_port base method

Base method call may fail due to potential concurrency issue while
consuming an IP address.
Change protects against this issue while called by metadata config.

Change-Id: I37c52aec9bfbcaa162d0fb7869b47df48bbd0310
This commit is contained in:
Kobi Samoray 2016-11-29 15:11:35 +02:00
parent 37487161bd
commit 25efc66b09
2 changed files with 7 additions and 2 deletions

View File

@ -434,7 +434,7 @@ class NsxVMetadataProxyHandler(object):
'port_security_enabled': False,
'tenant_id': None}}
port = self.nsxv_plugin.create_port(context, port_data)
port = self.nsxv_plugin.base_create_port(context, port_data)
address_groups = self._get_address_groups(
context, self.internal_net, rtr_id, is_proxy=True)
@ -662,7 +662,7 @@ class NsxVMetadataProxyHandler(object):
'port_security_enabled': False,
'tenant_id': None}}
self.nsxv_plugin.create_port(ctx, port_data)
self.nsxv_plugin.base_create_port(ctx, port_data)
address_groups = self._get_address_groups(
ctx,

View File

@ -44,6 +44,7 @@ from neutron import context as n_context
from neutron.db import _utils as db_utils
from neutron.db import agents_db
from neutron.db import allowedaddresspairs_db as addr_pair_db
from neutron.db import api as db_api
from neutron.db.availability_zone import router as router_az_db
from neutron.db import db_base_plugin_v2
from neutron.db import dns_db
@ -1317,6 +1318,10 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
msg = _('Address pairs should have same MAC as the port')
raise n_exc.BadRequest(resource='address_pairs', msg=msg)
@db_api.retry_db_errors
def base_create_port(self, context, port):
return super(NsxVPluginV2, self).create_port(context, port)
def create_port(self, context, port):
port_data = port['port']
with context.session.begin(subtransactions=True):