Skip to content

Commit

Permalink
Big Switch: Stop watchdog on interval of 0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kevinbenton committed Jun 18, 2014
1 parent 24718e6 commit 60c1b9e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions etc/neutron/plugins/bigswitch/restproxy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion neutron/plugins/bigswitch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"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.")),
Expand Down
4 changes: 4 additions & 0 deletions neutron/plugins/bigswitch/servermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ def _consistency_watchdog(self, polling_interval=60):
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
Expand Down
9 changes: 9 additions & 0 deletions neutron/tests/unit/bigswitch/test_servermanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ def test_sticky_cert_fetch_fail(self):
)
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 = []
Expand Down

0 comments on commit 60c1b9e

Please sign in to comment.