Browse Source

Migrate OvnWorker to a separate location

This patch migrates OvnWorker to a separate plugin file, so
that importing ovsdb_monitor in any other process( like Octavia )
does not cause any duplicate configuration issues.

Change-Id: I16a7f9971f4e429512e959f36ac745c98010b2a0
Reedip 4 months ago
parent
commit
41fa7e8a80

+ 1
- 1
doc/source/contributor/design/ovn_worker.rst View File

@@ -10,7 +10,7 @@ port's status to 'ACTIVE' or 'DOWN' in the db, it needs to monitor the
10 10
 OVN Northbound db. A neutron worker is created for this purpose.
11 11
 
12 12
 The implementation of the ovn worker can be found here -
13
-'networking_ovn.ovsdb.ovsdb_monitor.OvnWorker'.
13
+'networking_ovn.ovsdb.worker.OvnWorker'.
14 14
 
15 15
 Neutron service will create 'n' api workers and 'm' rpc workers and 1 ovn
16 16
 worker (all these workers are separate processes).

+ 3
- 3
networking_ovn/ml2/mech_driver.py View File

@@ -52,7 +52,7 @@ from networking_ovn.ml2 import qos_driver
52 52
 from networking_ovn.ml2 import trunk_driver
53 53
 from networking_ovn import ovn_db_sync
54 54
 from networking_ovn.ovsdb import impl_idl_ovn
55
-from networking_ovn.ovsdb import ovsdb_monitor
55
+from networking_ovn.ovsdb import worker
56 56
 
57 57
 
58 58
 LOG = log.getLogger(__name__)
@@ -193,7 +193,7 @@ class OVNMechanismDriver(api.MechanismDriver):
193 193
         # Now IDL connections can be safely used.
194 194
         self._post_fork_event.set()
195 195
 
196
-        if utils.get_method_class(trigger) == ovsdb_monitor.OvnWorker:
196
+        if utils.get_method_class(trigger) == worker.OvnWorker:
197 197
             # Call the synchronization task if its ovn worker
198 198
             # This sync neutron DB to OVN-NB DB only in inconsistent states
199 199
             self.nb_synchronizer = ovn_db_sync.OvnNbSynchronizer(
@@ -695,7 +695,7 @@ class OVNMechanismDriver(api.MechanismDriver):
695 695
         workers, can return a sequence of worker instances.
696 696
         """
697 697
         # See doc/source/design/ovn_worker.rst for more details.
698
-        return [ovsdb_monitor.OvnWorker(), maintenance.MaintenanceWorker()]
698
+        return [worker.OvnWorker(), maintenance.MaintenanceWorker()]
699 699
 
700 700
     def _update_subport_host_if_needed(self, port_id):
701 701
         parent_port = self._ovn_client.get_parent_port(port_id)

+ 2
- 1
networking_ovn/ovsdb/impl_idl_ovn.py View File

@@ -34,6 +34,7 @@ from networking_ovn.common import exceptions as ovn_exc
34 34
 from networking_ovn.common import utils
35 35
 from networking_ovn.ovsdb import commands as cmd
36 36
 from networking_ovn.ovsdb import ovsdb_monitor
37
+from networking_ovn.ovsdb import worker
37 38
 
38 39
 
39 40
 LOG = log.getLogger(__name__)
@@ -135,7 +136,7 @@ def get_connection(db_class, trigger=None, driver=None):
135 136
         args = (cfg.get_ovn_sb_connection(), 'OVN_Southbound')
136 137
         cls = ovsdb_monitor.OvnSbIdl
137 138
 
138
-    if trigger and utils.get_method_class(trigger) == ovsdb_monitor.OvnWorker:
139
+    if trigger and utils.get_method_class(trigger) == worker.OvnWorker:
139 140
         idl_ = cls.from_server(*args, driver=driver)
140 141
     else:
141 142
         if db_class == OvsdbSbOvnIdl:

+ 0
- 22
networking_ovn/ovsdb/ovsdb_monitor.py View File

@@ -12,11 +12,9 @@
12 12
 #    License for the specific language governing permissions and limitations
13 13
 #    under the License.
14 14
 
15
-from neutron.common import config
16 15
 from neutron_lib.plugins import constants
17 16
 from neutron_lib.plugins import directory
18 17
 from neutron_lib.utils import helpers
19
-from neutron_lib import worker
20 18
 from oslo_log import log
21 19
 from ovs.stream import Stream
22 20
 from ovsdbapp.backend.ovs_idl import connection
@@ -383,23 +381,3 @@ def _check_and_set_ssl_files(schema_name):
383 381
 
384 382
     if ca_cert_file:
385 383
         Stream.ssl_set_ca_cert_file(ca_cert_file)
386
-
387
-
388
-class OvnWorker(worker.BaseWorker):
389
-    def start(self):
390
-        super(OvnWorker, self).start()
391
-        # NOTE(twilson) The super class will trigger the post_fork_initialize
392
-        # in the driver, which starts the connection/IDL notify loop which
393
-        # keeps the process from exiting
394
-
395
-    def stop(self):
396
-        """Stop service."""
397
-        # TODO(numans)
398
-
399
-    def wait(self):
400
-        """Wait for service to complete."""
401
-        # TODO(numans)
402
-
403
-    @staticmethod
404
-    def reset():
405
-        config.reset_service()

+ 36
- 0
networking_ovn/ovsdb/worker.py View File

@@ -0,0 +1,36 @@
1
+# Copyright 2016 Red Hat, Inc.
2
+#
3
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+#    not use this file except in compliance with the License. You may obtain
5
+#    a copy of the License at
6
+#
7
+#         http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+#    Unless required by applicable law or agreed to in writing, software
10
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+#    License for the specific language governing permissions and limitations
13
+#    under the License.
14
+
15
+from neutron.common import config
16
+from neutron_lib import worker
17
+
18
+
19
+class OvnWorker(worker.BaseWorker):
20
+    def start(self):
21
+        super(OvnWorker, self).start()
22
+        # NOTE(twilson) The super class will trigger the post_fork_initialize
23
+        # in the driver, which starts the connection/IDL notify loop which
24
+        # keeps the process from exiting
25
+
26
+    def stop(self):
27
+        """Stop service."""
28
+        # TODO(numans)
29
+
30
+    def wait(self):
31
+        """Wait for service to complete."""
32
+        # TODO(numans)
33
+
34
+    @staticmethod
35
+    def reset():
36
+        config.reset_service()

+ 2
- 1
networking_ovn/tests/functional/base.py View File

@@ -33,6 +33,7 @@ from ovsdbapp.backend.ovs_idl import connection
33 33
 from networking_ovn.db import models  # noqa
34 34
 from networking_ovn.ovsdb import impl_idl_ovn
35 35
 from networking_ovn.ovsdb import ovsdb_monitor
36
+from networking_ovn.ovsdb import worker
36 37
 from networking_ovn.tests import base
37 38
 from networking_ovn.tests.functional.resources import process
38 39
 
@@ -210,7 +211,7 @@ class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase):
210 211
 
211 212
         trigger_cls = TriggerCls()
212 213
         if self.ovn_worker:
213
-            trigger_cls.trigger.__self__.__class__ = ovsdb_monitor.OvnWorker
214
+            trigger_cls.trigger.__self__.__class__ = worker.OvnWorker
214 215
             cfg.CONF.set_override('neutron_sync_mode', 'off', 'ovn')
215 216
 
216 217
         self.addCleanup(self.stop)

Loading…
Cancel
Save