From 63ff0486a2c3f92d055350bcc06a41219031fcd9 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Mon, 27 Jan 2020 19:15:19 +0000 Subject: [PATCH] Remove sleep command when retrieving OVS dp OVS agent is a single thread module executed on a os-ken AppManager context. os-ken uses, by default (and no other implementation is available today [1]), "eventlet" threads. Those threads are scheduled manually by the code itself; the context switch is done through yielding. The easiest way to do this is by executing: eventlet.sleep() If the assigned thread is not ready to take the GIL and do not yield back the executor, other threads will starve and eventually will timeout. This patch removes the "sleep" command during the DP retrieval. This will keep the executor on the current thread and will prevent the execution timeouts, as seen in the bug related. [1]https://opendev.org/openstack/os-ken/src/commit/1f751b2d7d385a75d4255934694177d6fd6f012f/os_ken/lib/hub.py Closes-Bug: #1861269 Change-Id: I19e1af1bda788ed970d30ab251e895f7daa11e39 (cherry picked from commit 740741864adc142b9bb037e92fd563cae124046a) --- .../drivers/openvswitch/agent/openflow/native/ofswitch.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py index e816d99e3d2..7c6281279e2 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ofswitch.py @@ -70,14 +70,13 @@ class OpenFlowSwitchMixin(object): dp = ofctl_api.get_datapath(self._app, dpid_int) if dp is not None: break - # The switch has not established a connection to us. - # Wait for a little. + # The switch has not established a connection to us; retry again + # until timeout. if timeutils.now() > start_time + timeout_sec: m = _("Switch connection timeout") LOG.error(m) # NOTE(yamamoto): use RuntimeError for compat with ovs_lib raise RuntimeError(m) - eventlet.sleep(1) return dp def _send_msg(self, msg, reply_cls=None, reply_multi=False,