commit 5b0715d96700d1c288f601b3ecb2cad507c2c134 Author: Terry Wilson Date: Thu Oct 15 12:53:36 2020 -0500 Fix leaked file descriptors by cleaning up objects A reference to the ovsdbapp Connection object is stored on the the API impl class and it is causing the object to stick around and its pipe fds to never close. Ultimately, python-ovs's call to select() is limited to 1024 file descriptors and will eventually error out. This deletes the connection and api objects explicitly when we are done with them. Change-Id: I97b27eaa293fb161724d34da88b4398f8b590c33 Co-authored-by: Brian Haley Closes-Bug: #1894136 diff --git a/ovn_octavia_provider/helper.py b/ovn_octavia_provider/helper.py index c1edf90..1f7fa6f 100644 --- a/ovn_octavia_provider/helper.py +++ b/ovn_octavia_provider/helper.py @@ -116,6 +116,7 @@ class OvnProviderHelper(object): self.requests.put({'type': ovn_const.REQ_TYPE_EXIT}) self.helper_thread.join() self.ovn_nbdb.stop() + del self.ovn_nbdb_api @staticmethod def _map_val(row, col, key): diff --git a/ovn_octavia_provider/ovsdb/impl_idl_ovn.py b/ovn_octavia_provider/ovsdb/impl_idl_ovn.py index e8731d8..124f620 100644 --- a/ovn_octavia_provider/ovsdb/impl_idl_ovn.py +++ b/ovn_octavia_provider/ovsdb/impl_idl_ovn.py @@ -175,10 +175,11 @@ class OvnNbIdlForLb(ovsdb_monitor.OvnIdl): def stop(self): # Close the running connection if it has been initalized - if ((hasattr(self, 'conn') and not - self.conn.stop(timeout=config.get_ovn_ovsdb_timeout()))): - LOG.debug("Connection terminated to OvnNb " - "but a thread is still alive") + if hasattr(self, 'conn'): + if not self.conn.stop(timeout=config.get_ovn_ovsdb_timeout()): + LOG.debug("Connection terminated to OvnNb " + "but a thread is still alive") + del self.conn # complete the shutdown for the event handler self.notify_handler.shutdown() # Close the idl session