Move process monitor settings to neutron.conf AGENT section
Instead of defining specific settings on each agent configuration file for later patches in the series, we provide a single point of configuration in the AGENT section of the neutron.conf file, which could yet be overriden per agent config file if needed. Partially Implements: blueprint agent-child-processes-status Change-Id: I8a6351c96b8699fdba50009fa9eace337b937a34
This commit is contained in:
parent
ffe91ecad5
commit
166206143d
|
@ -588,6 +588,15 @@ lock_path = $state_path/lock
|
|||
# not required, set this to False for a performance improvement.
|
||||
# use_helper_for_ns_read = True
|
||||
|
||||
# The interval to check external processes for failure in seconds (0=disabled)
|
||||
# check_child_processes_interval = 0
|
||||
|
||||
# Action to take when an external process spawned by an agent dies
|
||||
# Values:
|
||||
# respawn - Respawns the external process
|
||||
# exit - Exits the agent
|
||||
# check_child_processes_action = respawn
|
||||
|
||||
# =========== items for agent management extension =============
|
||||
# seconds between nodes reporting state to server; should be less than
|
||||
# agent_down_time, best if it is half or less than agent_down_time
|
||||
|
|
|
@ -55,6 +55,15 @@ IPTABLES_OPTS = [
|
|||
help=_("Add comments to iptables rules.")),
|
||||
]
|
||||
|
||||
PROCESS_MONITOR_OPTS = [
|
||||
cfg.StrOpt('check_child_processes_action', default='respawn',
|
||||
choices=['respawn', 'exit'],
|
||||
help=_('Action to be executed when a child process dies')),
|
||||
cfg.IntOpt('check_child_processes_interval', default=0,
|
||||
help=_('Interval between checks of child process liveness '
|
||||
'(seconds), use 0 to disable')),
|
||||
]
|
||||
|
||||
|
||||
def get_log_args(conf, log_file_name):
|
||||
cmd_args = []
|
||||
|
@ -105,6 +114,10 @@ def register_iptables_opts(conf):
|
|||
conf.register_opts(IPTABLES_OPTS, 'AGENT')
|
||||
|
||||
|
||||
def register_process_monitor_opts(conf):
|
||||
conf.register_opts(PROCESS_MONITOR_OPTS, 'AGENT')
|
||||
|
||||
|
||||
def get_root_helper(conf):
|
||||
root_helper = conf.AGENT.root_helper
|
||||
if root_helper != 'sudo':
|
||||
|
|
|
@ -18,6 +18,7 @@ import eventlet
|
|||
from oslo.config import cfg
|
||||
from oslo_concurrency import lockutils
|
||||
|
||||
from neutron.agent.common import config as agent_cfg
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.agent.linux import utils
|
||||
from neutron.i18n import _LE
|
||||
|
@ -30,16 +31,11 @@ OPTS = [
|
|||
cfg.StrOpt('external_pids',
|
||||
default='$state_path/external/pids',
|
||||
help=_('Location to store child pid files')),
|
||||
cfg.StrOpt('check_child_processes_action', default='respawn',
|
||||
choices=['respawn', 'exit'],
|
||||
help=_('Action to be executed when a child process dies')),
|
||||
cfg.IntOpt('check_child_processes_interval', default=0,
|
||||
help=_('Interval between checks of child process liveness '
|
||||
'(seconds), use 0 to disable')),
|
||||
]
|
||||
|
||||
|
||||
cfg.CONF.register_opts(OPTS)
|
||||
agent_cfg.register_process_monitor_opts(cfg.CONF)
|
||||
|
||||
|
||||
class ProcessManager(object):
|
||||
|
@ -154,7 +150,7 @@ class ProcessMonitor(object):
|
|||
|
||||
self._process_managers = {}
|
||||
|
||||
if self._config.check_child_processes_interval:
|
||||
if self._config.AGENT.check_child_processes_interval:
|
||||
self._spawn_checking_thread()
|
||||
|
||||
def enable(self, uuid, cmd_callback, namespace=None, service=None,
|
||||
|
@ -238,12 +234,12 @@ class ProcessMonitor(object):
|
|||
|
||||
def _periodic_checking_thread(self):
|
||||
while True:
|
||||
eventlet.sleep(self._config.check_child_processes_interval)
|
||||
eventlet.sleep(self._config.AGENT.check_child_processes_interval)
|
||||
eventlet.spawn(self._check_child_processes)
|
||||
|
||||
def _execute_action(self, service_id):
|
||||
action_function = getattr(
|
||||
self, "_%s_action" % self._config.check_child_processes_action)
|
||||
action = self._config.AGENT.check_child_processes_action
|
||||
action_function = getattr(self, "_%s_action" % action)
|
||||
action_function(service_id)
|
||||
|
||||
def _respawn_action(self, service_id):
|
||||
|
|
|
@ -29,13 +29,13 @@ class BaseTestProcessMonitor(base.BaseSudoTestCase):
|
|||
def setUp(self):
|
||||
super(BaseTestProcessMonitor, self).setUp()
|
||||
self._exit_handler_called = False
|
||||
cfg.CONF.set_override('check_child_processes_interval', 1)
|
||||
cfg.CONF.set_override('check_child_processes_interval', 1, 'AGENT')
|
||||
self._child_processes = []
|
||||
self._ext_processes = None
|
||||
self.addCleanup(self.cleanup_spawned_children)
|
||||
|
||||
def create_child_processes_manager(self, action):
|
||||
cfg.CONF.set_override('check_child_processes_action', action)
|
||||
cfg.CONF.set_override('check_child_processes_action', action, 'AGENT')
|
||||
self._ext_processes = external_process.ProcessMonitor(
|
||||
config=cfg.CONF,
|
||||
root_helper=None,
|
||||
|
@ -88,7 +88,8 @@ class BaseTestProcessMonitor(base.BaseSudoTestCase):
|
|||
# we need to allow extra_time for the check process to happen
|
||||
# and properly execute action over the gone processes under
|
||||
# high load conditions
|
||||
max_wait_time = cfg.CONF.check_child_processes_interval + extra_time
|
||||
max_wait_time = (
|
||||
cfg.CONF.AGENT.check_child_processes_interval + extra_time)
|
||||
with self.assert_max_execution_time(max_wait_time):
|
||||
while not exit_condition():
|
||||
eventlet.sleep(0.01)
|
||||
|
|
|
@ -44,8 +44,8 @@ class BaseTestProcessMonitor(base.BaseTestCase):
|
|||
def create_child_process_monitor(self, action):
|
||||
self.exit_handler = mock.Mock()
|
||||
conf = mock.Mock()
|
||||
conf.check_child_processes_action = action
|
||||
conf.check_child_processes = True
|
||||
conf.AGENT.check_child_processes_action = action
|
||||
conf.AGENT.check_child_processes = True
|
||||
self.pmonitor = external_process.ProcessMonitor(
|
||||
config=conf,
|
||||
root_helper=None,
|
||||
|
|
Loading…
Reference in New Issue