From 60c1b9e227fdfcae8e3660ffbd5062eb6a4abb33 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Wed, 18 Jun 2014 14:08:17 -0700 Subject: [PATCH] Big Switch: Stop watchdog on interval of 0 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 | 5 +++++ neutron/plugins/bigswitch/config.py | 2 +- neutron/plugins/bigswitch/servermanager.py | 4 ++++ neutron/tests/unit/bigswitch/test_servermanager.py | 9 +++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/etc/neutron/plugins/bigswitch/restproxy.ini b/etc/neutron/plugins/bigswitch/restproxy.ini index 3a8283f81..256f7855b 100644 --- a/etc/neutron/plugins/bigswitch/restproxy.ini +++ b/etc/neutron/plugins/bigswitch/restproxy.ini @@ -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 : (default: 60 seconds) # server_timeout : (default: 10 seconds) # neutron_id : (default: neutron-) # 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 diff --git a/neutron/plugins/bigswitch/config.py b/neutron/plugins/bigswitch/config.py index 540899b84..4646319c9 100644 --- a/neutron/plugins/bigswitch/config.py +++ b/neutron/plugins/bigswitch/config.py @@ -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.")), diff --git a/neutron/plugins/bigswitch/servermanager.py b/neutron/plugins/bigswitch/servermanager.py index c39c4e9f0..313010bd9 100644 --- a/neutron/plugins/bigswitch/servermanager.py +++ b/neutron/plugins/bigswitch/servermanager.py @@ -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 diff --git a/neutron/tests/unit/bigswitch/test_servermanager.py b/neutron/tests/unit/bigswitch/test_servermanager.py index 3a54e315b..7523b9a4d 100644 --- a/neutron/tests/unit/bigswitch/test_servermanager.py +++ b/neutron/tests/unit/bigswitch/test_servermanager.py @@ -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 = [] -- 2.45.2