[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
This commit is contained in:
Daniel Alvarez Sanchez 2021-11-04 14:34:32 +01:00 committed by Daniel Alvarez
parent dd73477036
commit 7874c57601
2 changed files with 5 additions and 3 deletions

View File

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

@ -103,6 +103,7 @@ class TestOVNMechanismDriverBase(MechDriverSetupBase,
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()
neutron_agent.AgentCache(self.mech_driver)
@ -135,7 +136,7 @@ class TestOVNMechanismDriverBase(MechDriverSetupBase,
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:
@ -147,7 +148,7 @@ class TestOVNMechanismDriverBase(MechDriverSetupBase,
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"]]}]\'')