Merge "NSX: Fix possible deadlock in sync code"
This commit is contained in:
commit
e8941a30cd
@ -297,17 +297,17 @@ class NvpSynchronizer():
|
|||||||
neutron_nvp_mappings[neutron_id] = (
|
neutron_nvp_mappings[neutron_id] = (
|
||||||
neutron_nvp_mappings.get(neutron_id, []) +
|
neutron_nvp_mappings.get(neutron_id, []) +
|
||||||
[self._nvp_cache[ls_uuid]])
|
[self._nvp_cache[ls_uuid]])
|
||||||
with ctx.session.begin(subtransactions=True):
|
# Fetch neutron networks from database
|
||||||
# Fetch neutron networks from database
|
filters = {'router:external': [False]}
|
||||||
filters = {'router:external': [False]}
|
if not scan_missing:
|
||||||
if not scan_missing:
|
filters['id'] = neutron_net_ids
|
||||||
filters['id'] = neutron_net_ids
|
# TODO(salv-orlando): Filter out external networks
|
||||||
# TODO(salv-orlando): Filter out external networks
|
networks = self._plugin._get_collection_query(
|
||||||
for network in self._plugin._get_collection_query(
|
ctx, models_v2.Network, filters=filters)
|
||||||
ctx, models_v2.Network, filters=filters):
|
for network in networks:
|
||||||
lswitches = neutron_nvp_mappings.get(network['id'], [])
|
lswitches = neutron_nvp_mappings.get(network['id'], [])
|
||||||
lswitches = [lswitch.get('data') for lswitch in lswitches]
|
lswitches = [lswitch.get('data') for lswitch in lswitches]
|
||||||
self.synchronize_network(ctx, network, lswitches)
|
self.synchronize_network(ctx, network, lswitches)
|
||||||
|
|
||||||
def synchronize_router(self, context, neutron_router_data,
|
def synchronize_router(self, context, neutron_router_data,
|
||||||
lrouter=None):
|
lrouter=None):
|
||||||
@ -348,15 +348,15 @@ class NvpSynchronizer():
|
|||||||
return
|
return
|
||||||
neutron_router_mappings = (
|
neutron_router_mappings = (
|
||||||
dict((lr_uuid, self._nvp_cache[lr_uuid]) for lr_uuid in lr_uuids))
|
dict((lr_uuid, self._nvp_cache[lr_uuid]) for lr_uuid in lr_uuids))
|
||||||
with ctx.session.begin(subtransactions=True):
|
# Fetch neutron routers from database
|
||||||
# Fetch neutron routers from database
|
filters = ({} if scan_missing else
|
||||||
filters = ({} if scan_missing else
|
{'id': neutron_router_mappings.keys()})
|
||||||
{'id': neutron_router_mappings.keys()})
|
routers = self._plugin._get_collection_query(
|
||||||
for router in self._plugin._get_collection_query(
|
ctx, l3_db.Router, filters=filters)
|
||||||
ctx, l3_db.Router, filters=filters):
|
for router in routers:
|
||||||
lrouter = neutron_router_mappings.get(router['id'])
|
lrouter = neutron_router_mappings.get(router['id'])
|
||||||
self.synchronize_router(
|
self.synchronize_router(
|
||||||
ctx, router, lrouter and lrouter.get('data'))
|
ctx, router, lrouter and lrouter.get('data'))
|
||||||
|
|
||||||
def synchronize_port(self, context, neutron_port_data,
|
def synchronize_port(self, context, neutron_port_data,
|
||||||
lswitchport=None, ext_networks=None):
|
lswitchport=None, ext_networks=None):
|
||||||
@ -425,24 +425,24 @@ class NvpSynchronizer():
|
|||||||
if neutron_port_id:
|
if neutron_port_id:
|
||||||
neutron_port_mappings[neutron_port_id] = (
|
neutron_port_mappings[neutron_port_id] = (
|
||||||
self._nvp_cache[lp_uuid])
|
self._nvp_cache[lp_uuid])
|
||||||
with ctx.session.begin(subtransactions=True):
|
# Fetch neutron ports from database
|
||||||
# Fetch neutron ports from database
|
# At the first sync we need to fetch all ports
|
||||||
# At the first sync we need to fetch all ports
|
filters = ({} if scan_missing else
|
||||||
filters = ({} if scan_missing else
|
{'id': neutron_port_mappings.keys()})
|
||||||
{'id': neutron_port_mappings.keys()})
|
# TODO(salv-orlando): Work out a solution for avoiding
|
||||||
# TODO(salv-orlando): Work out a solution for avoiding
|
# this query
|
||||||
# this query
|
ext_nets = [net['id'] for net in ctx.session.query(
|
||||||
ext_nets = [net['id'] for net in ctx.session.query(
|
models_v2.Network).join(
|
||||||
models_v2.Network).join(
|
external_net_db.ExternalNetwork,
|
||||||
external_net_db.ExternalNetwork,
|
(models_v2.Network.id ==
|
||||||
(models_v2.Network.id ==
|
external_net_db.ExternalNetwork.network_id))]
|
||||||
external_net_db.ExternalNetwork.network_id))]
|
ports = self._plugin._get_collection_query(
|
||||||
for port in self._plugin._get_collection_query(
|
ctx, models_v2.Port, filters=filters)
|
||||||
ctx, models_v2.Port, filters=filters):
|
for port in ports:
|
||||||
lswitchport = neutron_port_mappings.get(port['id'])
|
lswitchport = neutron_port_mappings.get(port['id'])
|
||||||
self.synchronize_port(
|
self.synchronize_port(
|
||||||
ctx, port, lswitchport and lswitchport.get('data'),
|
ctx, port, lswitchport and lswitchport.get('data'),
|
||||||
ext_networks=ext_nets)
|
ext_networks=ext_nets)
|
||||||
|
|
||||||
def _get_chunk_size(self, sp):
|
def _get_chunk_size(self, sp):
|
||||||
# NOTE(salv-orlando): Try to use __future__ for this routine only?
|
# NOTE(salv-orlando): Try to use __future__ for this routine only?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user