]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Big Switch: Stop watchdog on interval of 0
authorKevin Benton <blak111@gmail.com>
Wed, 18 Jun 2014 21:08:17 +0000 (14:08 -0700)
committerKevin Benton <blak111@gmail.com>
Wed, 18 Jun 2014 21:11:08 +0000 (14:11 -0700)
Corrects the behavior of the watchdog process
to exit if the user configures the polling interval
to be 0.

Also adds missing documentation to sample config.

Change-Id: I17b566867c21f42985cc4662f56d32db690f471f
Closes-Bug: #1332334

etc/neutron/plugins/bigswitch/restproxy.ini
neutron/plugins/bigswitch/config.py
neutron/plugins/bigswitch/servermanager.py
neutron/tests/unit/bigswitch/test_servermanager.py

index 3a8283f8166b9ee439c61b4148a1fbf5a9912df7..256f7855b858679b29e1ce307f15b0a90d144627 100644 (file)
@@ -12,6 +12,7 @@
 #   ssl_sticky            :  True | False                 (default: True)
 #   sync_data             :  True | False                 (default: False)
 #   auto_sync_on_failure  :  True | False                 (default: True)
+#   consistency_interval  :  <integer>                    (default: 60 seconds)
 #   server_timeout        :  <integer>                    (default: 10 seconds)
 #   neutron_id            :  <string>                     (default: neutron-<hostname>)
 #   add_meta_server_route :  True | False                 (default: True)
@@ -47,6 +48,10 @@ servers=localhost:8080
 # synchronization to the controller.
 # auto_sync_on_failure=True
 
+# Time between verifications that the backend controller
+# database is consistent with Neutron. (0 to disable)
+# consistency_interval = 60
+
 # Maximum number of seconds to wait for proxy request to connect and complete.
 # server_timeout=10
 
index 540899b8415922f9720d5a18b2934278a8c8cece..4646319c9135895bd1273ad5576924152a9ce819 100644 (file)
@@ -63,7 +63,7 @@ restproxy_opts = [
                        "synchronization to the controller.")),
     cfg.IntOpt('consistency_interval', default=60,
                help=_("Time between verifications that the backend controller "
-                      "database is consistent with Neutron")),
+                      "database is consistent with Neutron. (0 to disable)")),
     cfg.IntOpt('server_timeout', default=10,
                help=_("Maximum number of seconds to wait for proxy request "
                       "to connect and complete.")),
index c39c4e9f09518a1d25017b51de07f5669147e702..313010bd9654ec1fcd3a31ec2f34c67f8267612b 100644 (file)
@@ -550,6 +550,10 @@ class ServerPool(object):
             LOG.warning(_("Backend server(s) do not support automated "
                           "consitency checks."))
             return
+        if not polling_interval:
+            LOG.warning(_("Consistency watchdog disabled by polling interval "
+                          "setting of %s."), polling_interval)
+            return
         while True:
             # If consistency is supported, all we have to do is make any
             # rest call and the consistency header will be added. If it
index 3a54e315b8c234e27b9ab417b81e4260e1df82f2..7523b9a4de7cfe3229d759b41ae739732f16342e 100644 (file)
@@ -74,6 +74,15 @@ class ServerManagerTests(test_rp.BigSwitchProxyPluginV2TestCase):
             )
             sslgetmock.assert_has_calls([mock.call(('example.org', 443))])
 
+    def test_consistency_watchdog_stops_with_0_polling_interval(self):
+        pl = manager.NeutronManager.get_plugin()
+        pl.servers.capabilities = ['consistency']
+        self.watch_p.stop()
+        with mock.patch('eventlet.sleep') as smock:
+            # should return immediately a polling interval of 0
+            pl.servers._consistency_watchdog(0)
+            self.assertFalse(smock.called)
+
     def test_consistency_watchdog(self):
         pl = manager.NeutronManager.get_plugin()
         pl.servers.capabilities = []