Wait for ovsdb_monitor to be active before use it

There is a race between ovsdb_monitor becoming active and using
ovsdb_monitor. Sometimes, code [1] will be hit at ovs-agent startup.

The fix here will block the start of ovsdb_monitor, so that the
following code to use the ovsdb_monitor will have ovsdb_monitor be
active.

[1] https://goo.gl/RJX4I5
Closes-bug: #1584647

Change-Id: I893a3b250339006f50aa003686fb95d7f2465edc
This commit is contained in:
Hong Hui Xiao 2016-05-23 08:33:55 +00:00 committed by Hong Hui Xiao
parent c5fb78dfdd
commit 95ff46722d
3 changed files with 6 additions and 2 deletions

View File

@ -54,7 +54,7 @@ class InterfacePollingMinimizer(base_polling.BasePollingManager):
respawn_interval=ovsdb_monitor_respawn_interval)
def start(self):
self._monitor.start()
self._monitor.start(block=True)
def stop(self):
try:

View File

@ -45,7 +45,7 @@ class TestInterfacePollingMinimizer(base.BaseTestCase):
def test_start_calls_monitor_start(self):
with mock.patch.object(self.pm._monitor, 'start') as mock_start:
self.pm.start()
mock_start.assert_called_with()
mock_start.assert_called_with(block=True)
def test_stop_calls_monitor_stop(self):
with mock.patch.object(self.pm._monitor, 'stop') as mock_stop:

View File

@ -1795,6 +1795,8 @@ class TestOvsNeutronAgent(object):
with mock.patch.object(async_process.AsyncProcess, "_spawn"),\
mock.patch.object(async_process.AsyncProcess, "start"),\
mock.patch.object(async_process.AsyncProcess,
"is_active", return_value=True),\
mock.patch.object(async_process.AsyncProcess, "stop"),\
mock.patch.object(log.KeywordArgumentAdapter,
'exception') as log_exception,\
@ -1877,6 +1879,8 @@ class TestOvsNeutronAgent(object):
def test_rpc_loop_fail_to_process_network_ports_keep_flows(self):
with mock.patch.object(async_process.AsyncProcess, "_spawn"),\
mock.patch.object(async_process.AsyncProcess, "start"),\
mock.patch.object(async_process.AsyncProcess,
"is_active", return_value=True),\
mock.patch.object(async_process.AsyncProcess, "stop"),\
mock.patch.object(
self.mod_agent.OVSNeutronAgent,