# Minimize polling by monitoring ovsdb for interface changes
# minimize_polling = False
+# When minimize_polling = True, the number of seconds to wait before
+# respawning the ovsdb monitor after losing communication with it
+# ovsdb_monitor_respawn_interval = 30
+
# (ListOpt) The types of tenant network tunnels supported by the agent.
# Setting this will enable tunneling support in the agent. This can be set to
# either 'gre' or 'vxlan'. If this is unset, it will default to [] and
import eventlet
from neutron.agent.linux import ovsdb_monitor
+from neutron.plugins.openvswitch.common import constants
@contextlib.contextmanager
-def get_polling_manager(minimize_polling=False, root_helper=None):
+def get_polling_manager(minimize_polling=False,
+ root_helper=None,
+ ovsdb_monitor_respawn_interval=(
+ constants.DEFAULT_OVSDBMON_RESPAWN)):
if minimize_polling:
- pm = InterfacePollingMinimizer(root_helper=root_helper)
+ pm = InterfacePollingMinimizer(
+ root_helper=root_helper,
+ ovsdb_monitor_respawn_interval=ovsdb_monitor_respawn_interval)
pm.start()
else:
pm = AlwaysPoll()
class InterfacePollingMinimizer(BasePollingManager):
"""Monitors ovsdb to determine when polling is required."""
- def __init__(self, root_helper=None):
+ def __init__(self, root_helper=None,
+ ovsdb_monitor_respawn_interval=(
+ constants.DEFAULT_OVSDBMON_RESPAWN)):
+
super(InterfacePollingMinimizer, self).__init__()
self._monitor = ovsdb_monitor.SimpleInterfaceMonitor(
- root_helper=root_helper)
+ root_helper=root_helper,
+ respawn_interval=ovsdb_monitor_respawn_interval)
def start(self):
self._monitor.start()
bridge_mappings, root_helper,
polling_interval, tunnel_types=None,
veth_mtu=None, l2_population=False,
- minimize_polling=False):
+ minimize_polling=False,
+ ovsdb_monitor_respawn_interval=(
+ constants.DEFAULT_OVSDBMON_RESPAWN)):
'''Constructor.
:param integ_br: name of the integration bridge.
:param veth_mtu: MTU size for veth interfaces.
:param minimize_polling: Optional, whether to minimize polling by
monitoring ovsdb for interface changes.
+ :param ovsdb_monitor_respawn_interval: Optional, when using polling
+ minimization, the number of seconds to wait before respawning
+ the ovsdb monitor.
'''
self.veth_mtu = veth_mtu
self.root_helper = root_helper
self.polling_interval = polling_interval
self.minimize_polling = minimize_polling
+ self.ovsdb_monitor_respawn_interval = ovsdb_monitor_respawn_interval
if tunnel_types:
self.enable_tunneling = True
'elapsed': elapsed})
def daemon_loop(self):
- with polling.get_polling_manager(self.minimize_polling,
- self.root_helper) as pm:
+ with polling.get_polling_manager(
+ self.minimize_polling,
+ self.root_helper,
+ self.ovsdb_monitor_respawn_interval) as pm:
+
self.rpc_loop(polling_manager=pm)
default=False,
help=_("Minimize polling by monitoring ovsdb for interface "
"changes.")),
+ cfg.IntOpt('ovsdb_monitor_respawn_interval',
+ default=constants.DEFAULT_OVSDBMON_RESPAWN,
+ help=_("The number of seconds to wait before respawning the "
+ "ovsdb monitor after losing communication with it")),
cfg.ListOpt('tunnel_types', default=DEFAULT_TUNNEL_TYPES,
help=_("Network types supported by the agent "
"(gre and/or vxlan)")),
FLOOD_TO_TUN = 21
# Map tunnel types to tables number
TUN_TABLE = {TYPE_GRE: GRE_TUN_TO_LV, TYPE_VXLAN: VXLAN_TUN_TO_LV}
+
+# The default respawn interval for the ovsdb monitor
+DEFAULT_OVSDBMON_RESPAWN = 30
old_pid = self.monitor._process.pid
output1 = self.collect_initial_output()
pid = self.monitor._get_pid_to_kill()
- self.monitor._reset_queues()
self.monitor._kill_process(pid)
+ self.monitor._reset_queues()
while (self.monitor._process.pid == old_pid):
eventlet.sleep(0.01)
output2 = self.collect_initial_output()
'neutron.agent.linux.polling.get_polling_manager') as mock_get_pm:
with mock.patch.object(self.agent, 'rpc_loop') as mock_loop:
self.agent.daemon_loop()
- mock_get_pm.assert_called_with(False, 'sudo')
+ mock_get_pm.assert_called_with(False, 'sudo',
+ constants.DEFAULT_OVSDBMON_RESPAWN)
mock_loop.called_once()
def test_setup_tunnel_port_error_negative(self):