From: Terry Wilson Date: Tue, 29 Sep 2015 02:01:30 +0000 (-0500) Subject: Just call set-manager if connecting fails X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c561c7c20acef7227e2eab2be30a2626e16d2354;p=openstack-build%2Fneutron-build.git Just call set-manager if connecting fails Instead of calling set-manager every init, only call it when getting the schema fails inside of Connection.start() which is only called once. Closes-Bug: #1499784 Change-Id: Ib28cd912e1f2eba318a6b0a82269919a1c95312d --- diff --git a/neutron/agent/ovsdb/impl_idl.py b/neutron/agent/ovsdb/impl_idl.py index c4459b94e..86c757d26 100644 --- a/neutron/agent/ovsdb/impl_idl.py +++ b/neutron/agent/ovsdb/impl_idl.py @@ -23,7 +23,6 @@ from ovs.db import idl from neutron.agent.ovsdb import api from neutron.agent.ovsdb.native import commands as cmd from neutron.agent.ovsdb.native import connection -from neutron.agent.ovsdb.native import helpers from neutron.agent.ovsdb.native import idlutils from neutron.i18n import _LE @@ -123,11 +122,6 @@ class OvsdbIdl(api.API): def __init__(self, context): super(OvsdbIdl, self).__init__(context) - # it's a chicken and egg problem: by default, the manager that - # corresponds to the connection URI is in most cases not enabled in - # local ovsdb, so we still need ovs-vsctl to set it to allow - # connections - helpers.enable_connection_uri(self.ovsdb_connection.connection) OvsdbIdl.ovsdb_connection.start() self.idl = OvsdbIdl.ovsdb_connection.idl diff --git a/neutron/agent/ovsdb/native/connection.py b/neutron/agent/ovsdb/native/connection.py index 7f2b10a15..56cd7cc65 100644 --- a/neutron/agent/ovsdb/native/connection.py +++ b/neutron/agent/ovsdb/native/connection.py @@ -19,7 +19,9 @@ import traceback from ovs.db import idl from ovs import poller +import retrying +from neutron.agent.ovsdb.native import helpers from neutron.agent.ovsdb.native import idlutils @@ -62,8 +64,21 @@ class Connection(object): if self.idl is not None: return - helper = idlutils.get_schema_helper(self.connection, - self.schema_name) + try: + helper = idlutils.get_schema_helper(self.connection, + self.schema_name) + except Exception: + # We may have failed do to set-manager not being called + helpers.enable_connection_uri(self.connection) + + # There is a small window for a race, so retry up to a second + @retrying.retry(wait_exponential_multiplier=10, + stop_max_delay=1000) + def do_get_schema_helper(): + return idlutils.get_schema_helper(self.connection, + self.schema_name) + helper = do_get_schema_helper() + helper.register_all() self.idl = idl.Idl(self.connection, helper) idlutils.wait_for_change(self.idl, self.timeout)