[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

Conflicts:
    neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py

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 ee67324c17
commit 15e2da82c2
2 changed files with 5 additions and 3 deletions

View File

@ -1055,7 +1055,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

@ -91,6 +91,7 @@ class TestOVNMechanismDriver(test_plugin.Ml2PluginV2TestCase):
self.mech_driver._nb_ovn = fakes.FakeOvsdbNbOvnIdl()
self.mech_driver._sb_ovn = fakes.FakeOvsdbSbOvnIdl()
self.mech_driver._ovn_client._qos_driver = mock.Mock()
cfg.CONF.set_override('ovsdb_connection_timeout', 30, group='ovn')
self.nb_ovn = self.mech_driver._nb_ovn
self.sb_ovn = self.mech_driver._sb_ovn
@ -116,7 +117,7 @@ class TestOVNMechanismDriver(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:
@ -128,7 +129,7 @@ class TestOVNMechanismDriver(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"]]}]\'')