]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Just call set-manager if connecting fails
authorTerry Wilson <twilson@redhat.com>
Tue, 29 Sep 2015 02:01:30 +0000 (21:01 -0500)
committerTerry Wilson <twilson@redhat.com>
Wed, 30 Sep 2015 16:15:22 +0000 (11:15 -0500)
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

neutron/agent/ovsdb/impl_idl.py
neutron/agent/ovsdb/native/connection.py

index c4459b94e86c93fd163e0d8f7fa64bc9463a71e0..86c757d262f416f8e9b90fe51babb84b8350ef00 100644 (file)
@@ -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
 
index 7f2b10a1566d7970545fd4890b2d29587eccc441..56cd7cc65534e47a4cc3a66cca521205b99aaff4 100644 (file)
@@ -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)