Add configurable ovsdb monitor respawn interval
If minimize_polling=True and the ovsdb-client process died, the default respawn interval of 0 would mean that we'd start polling again. This patch adds the option ovsdb_monitor_respawn_interval and defaults it to 30 seconds. Change-Id: I12c1e05ec4d6d2bd4d84024a91116e2ac3974868 Close-Bug: 1243867
This commit is contained in:
parent
c84480dfc2
commit
ceea6a5520
@ -90,6 +90,10 @@
|
||||
# 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
|
||||
|
@ -19,12 +19,18 @@ import contextlib
|
||||
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()
|
||||
@ -86,10 +92,14 @@ class AlwaysPoll(BasePollingManager):
|
||||
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()
|
||||
|
@ -158,7 +158,9 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
|
||||
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.
|
||||
@ -173,6 +175,9 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
|
||||
: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
|
||||
@ -204,6 +209,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
|
||||
|
||||
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
|
||||
@ -1115,8 +1121,11 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
|
||||
'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)
|
||||
|
||||
|
||||
|
@ -66,6 +66,10 @@ agent_opts = [
|
||||
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)")),
|
||||
|
@ -48,3 +48,6 @@ UCAST_TO_TUN = 20
|
||||
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
|
||||
|
@ -120,8 +120,8 @@ class TestOvsdbMonitor(BaseMonitorTest):
|
||||
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()
|
||||
|
@ -588,7 +588,8 @@ class TestOvsNeutronAgent(base.BaseTestCase):
|
||||
'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):
|
||||
|
Loading…
Reference in New Issue
Block a user