dhcp_meta/rpc: cleaned up greenthread.sleep(0) calls

Those are (probably) artifacts from times when neutron was using
eventlet-incompatible sqlalchemy adaptors for mysql. I don't see a reason why
we may need those explicit yields otherwise.

Change-Id: Ibf89387b7c8a2e7f08b11da058aaabf78e21daaa
This commit is contained in:
Ihar Hrachyshka 2018-04-26 22:08:54 +00:00 committed by Adit Sarfaty
parent 7c3bcb2959
commit fa628e3f71

View File

@ -14,7 +14,6 @@
# under the License.
#
from eventlet import greenthread
from neutron_lib import constants as const
from neutron_lib import exceptions as ntn_exc
from oslo_config import cfg
@ -185,9 +184,7 @@ def _create_metadata_access_network(plugin, context, router_id):
'status': const.NET_STATUS_ACTIVE}
meta_net = plugin.create_network(context,
{'network': net_data})
greenthread.sleep(0) # yield
plugin.schedule_network(context, meta_net)
greenthread.sleep(0) # yield
# From this point on there will be resources to garbage-collect
# in case of failures
meta_sub = None
@ -207,10 +204,8 @@ def _create_metadata_access_network(plugin, context, router_id):
'host_routes': []}
meta_sub = plugin.create_subnet(context,
{'subnet': subnet_data})
greenthread.sleep(0) # yield
plugin.add_router_interface(context, router_id,
{'subnet_id': meta_sub['id']})
greenthread.sleep(0) # yield
# Tell to start the metadata agent proxy, only if we had success
_notify_rpc_agent(context, {'subnet': meta_sub}, 'subnet.create.end')
except (ntn_exc.NeutronException,
@ -231,12 +226,10 @@ def _destroy_metadata_access_network(plugin, context, router_id, ports):
meta_sub_id = meta_port['fixed_ips'][0]['subnet_id']
plugin.remove_router_interface(
context, router_id, {'port_id': meta_port['id']})
greenthread.sleep(0) # yield
context.session.expunge_all()
try:
# Remove network (this will remove the subnet too)
plugin.delete_network(context, meta_net_id)
greenthread.sleep(0) # yield
except (ntn_exc.NeutronException, nsx_exc.NsxPluginException,
api_exc.NsxApiException):
# must re-add the router interface