Merge "NSX|V: address DB lock wait timeouts in the plugin"

This commit is contained in:
Jenkins 2016-07-01 09:50:19 +00:00 committed by Gerrit Code Review
commit 920676f0ac
2 changed files with 11 additions and 3 deletions

View File

@ -251,7 +251,6 @@ def allocate_edge_vnic_with_tunnel_index(session, edge_id, network_id):
raise nsx_exc.NsxPluginException(err_msg=msg) raise nsx_exc.NsxPluginException(err_msg=msg)
binding['network_id'] = network_id binding['network_id'] = network_id
session.add(binding) session.add(binding)
session.flush()
return binding return binding

View File

@ -1042,6 +1042,10 @@ class EdgeManager(object):
def reuse_existing_dhcp_edge(self, context, edge_id, resource_id, def reuse_existing_dhcp_edge(self, context, edge_id, resource_id,
network_id): network_id):
app_size = vcns_const.SERVICE_SIZE_MAPPING['dhcp'] app_size = vcns_const.SERVICE_SIZE_MAPPING['dhcp']
# There may be edge cases when we are waiting for edges to deploy
# and the underlying db session may hit a timeout. So this creates
# a new session
context = q_context.get_admin_context()
nsxv_db.add_nsxv_router_binding( nsxv_db.add_nsxv_router_binding(
context.session, resource_id, context.session, resource_id,
edge_id, None, plugin_const.ACTIVE, edge_id, None, plugin_const.ACTIVE,
@ -1127,8 +1131,9 @@ class EdgeManager(object):
if new_id: if new_id:
LOG.debug("Select edge %s to support dhcp for network " LOG.debug("Select edge %s to support dhcp for network "
"%s", new_id, network_id) "%s", new_id, network_id)
self.reuse_existing_dhcp_edge( with locking.LockManager.get_lock(str(new_id)):
context, new_id, resource_id, network_id) self.reuse_existing_dhcp_edge(
context, new_id, resource_id, network_id)
else: else:
allocate_new_edge = True allocate_new_edge = True
else: else:
@ -1150,6 +1155,10 @@ class EdgeManager(object):
resource_id = (vcns_const.DHCP_EDGE_PREFIX + network_id)[:36] resource_id = (vcns_const.DHCP_EDGE_PREFIX + network_id)[:36]
edge_binding = nsxv_db.get_nsxv_router_binding(context.session, edge_binding = nsxv_db.get_nsxv_router_binding(context.session,
resource_id) resource_id)
if not edge_binding:
LOG.warning(_LW('Edge binding does not exist for network %s'),
network_id)
return
dhcp_binding = nsxv_db.get_edge_vnic_binding(context.session, dhcp_binding = nsxv_db.get_edge_vnic_binding(context.session,
edge_binding['edge_id'], edge_binding['edge_id'],
network_id) network_id)