From 9c3c718e244c60effdbdfb62628456bc9a6a5add Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Wed, 21 Apr 2021 16:35:22 +0000 Subject: [PATCH] Don't ever give up trying to connect to OVN DBs It doesn't really make since to give up connectimg to the OVN DBs since we can't do anything without them. If ovsdb-server is slow and takes more than timeout seconds, everything reconnecting after partial downloads and starting over is not going to make things better. We can change the behavior in ovsdbapp, but doing it without making non-backportable API changes isn't easily doable. The plan would be, after merging this back through stable, to modify ovsdbapp to allow setting different connection and txn timeouts and being able to disable the timeout in wait_for_change with a value of -1. Then in the main branch of neutron we can use that going forward. Closes-Bug: #1926653 Change-Id: Ia9e23113fdeebf0b99085da200c3d61b71567d36 (cherry picked from commit 39ccc0d6d6995b8d50baecc523dd30be034669a9) --- .../drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py | 13 +++++++++++++ .../drivers/ovn/mech_driver/ovsdb/test_impl_idl.py | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py index 91f63c9a9af..e83b7fff7c0 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/impl_idl_ovn.py @@ -39,6 +39,19 @@ from neutron.services.portforwarding import constants as pf_const LOG = log.getLogger(__name__) +# Override wait_for_change to not use a timeout so we always try to reconnect +def wait_for_change(idl_, timeout, seqno=None): + if seqno is None: + seqno = idl_.change_seqno + while idl_.change_seqno == seqno and not idl_.run(): + poller = idlutils.poller.Poller() + idl_.wait(poller) + poller.block() + + +idlutils.wait_for_change = wait_for_change + + class OvnNbTransaction(idl_trans.Transaction): def __init__(self, *args, **kwargs): diff --git a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py index f587c1b56f3..ad3cbe9f329 100644 --- a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py +++ b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_impl_idl.py @@ -15,6 +15,7 @@ import copy import uuid +from ovsdbapp.backend.ovs_idl import connection from ovsdbapp import constants as const from ovsdbapp import event as ovsdb_event from ovsdbapp.tests.functional import base @@ -259,3 +260,13 @@ class TestNbApi(BaseOvnIdlTest): lb_match = f(exp_fip_id) self.assertIn((lb_match['name'], lb_match['external_ids']), exp_values) + + +class TestIgnoreConnectionTimeout(BaseOvnIdlTest): + @classmethod + def create_connection(cls, schema): + idl = connection.OvsdbIdl.from_server(cls.schema_map[schema], schema) + return connection.Connection(idl, 0) + + def test_setUp_will_fail_if_this_is_broken(self): + pass