[ovn] Add timeout option to ovsdb-client command

Today, we invoke ovsdb-client to cleanup the MAC_Binding entries
without specifying any timeout. This can lead to workers blocking
forever if there's an issue with the connection to the server.

This patch is adding a timeout parameter to the command line to
prevent this condition.

Closes-Bug: #1948891
Related-Bug: #1946318

Signed-off-by: Daniel Alvarez Sanchez <dalvarez@redhat.com>
Change-Id: Id393cbec31dd64a795e85d756b7b843c9dfc59f3
(cherry picked from commit 7874c57601)
This commit is contained in:
Daniel Alvarez Sanchez 2021-11-04 14:34:32 +01:00 committed by Lucas Alvares Gomes
parent 557a529ac5
commit f37e0be349
2 changed files with 5 additions and 3 deletions

View File

@ -1096,7 +1096,8 @@ class OVNMechanismDriver(api.MechanismDriver):
def delete_mac_binding_entries(self, external_ip):
"""Delete all MAC_Binding entries associated to this IP address"""
cmd = ['ovsdb-client', 'transact', ovn_conf.get_ovn_sb_connection()]
cmd = ['ovsdb-client', 'transact', ovn_conf.get_ovn_sb_connection(),
'--timeout', str(ovn_conf.get_ovn_ovsdb_timeout())]
if ovn_conf.get_ovn_sb_private_key():
cmd += ['-p', ovn_conf.get_ovn_sb_private_key(), '-c',

View File

@ -88,6 +88,7 @@ class TestOVNMechanismDriverBase(test_plugin.Ml2PluginV2TestCase):
ovn_conf.cfg.CONF.set_override('dns_servers', ['8.8.8.8'],
group='ovn')
cfg.CONF.set_override('vlan_transparent', True)
cfg.CONF.set_override('ovsdb_connection_timeout', 30, group='ovn')
mock.patch.object(impl_idl_ovn.Backend, 'schema_helper').start()
super().setUp()
mm = directory.get_plugin().mechanism_manager
@ -125,7 +126,7 @@ class TestOVNMechanismDriverBase(test_plugin.Ml2PluginV2TestCase):
def test_delete_mac_binding_entries(self):
self.config(group='ovn', ovn_sb_private_key=None)
expected = ('ovsdb-client transact tcp:127.0.0.1:6642 '
expected = ('ovsdb-client transact tcp:127.0.0.1:6642 --timeout 30 '
'\'["OVN_Southbound", {"op": "delete", "table": '
'"MAC_Binding", "where": [["ip", "==", "1.1.1.1"]]}]\'')
with mock.patch.object(processutils, 'execute') as mock_execute:
@ -137,7 +138,7 @@ class TestOVNMechanismDriverBase(test_plugin.Ml2PluginV2TestCase):
self.config(group='ovn', ovn_sb_private_key='pk')
self.config(group='ovn', ovn_sb_certificate='cert')
self.config(group='ovn', ovn_sb_ca_cert='ca')
expected = ('ovsdb-client transact tcp:127.0.0.1:6642 '
expected = ('ovsdb-client transact tcp:127.0.0.1:6642 --timeout 30 '
'-p pk -c cert -C ca '
'\'["OVN_Southbound", {"op": "delete", "table": '
'"MAC_Binding", "where": [["ip", "==", "1.1.1.1"]]}]\'')