]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Move process monitor settings to neutron.conf AGENT section
authorMiguel Angel Ajo <mangelajo@redhat.com>
Thu, 22 Jan 2015 14:17:30 +0000 (14:17 +0000)
committerMiguel Angel Ajo <mangelajo@redhat.com>
Thu, 22 Jan 2015 21:37:55 +0000 (21:37 +0000)
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

etc/neutron.conf
neutron/agent/common/config.py
neutron/agent/linux/external_process.py
neutron/tests/functional/agent/linux/test_process_monitor.py
neutron/tests/unit/agent/linux/test_process_monitor.py

index 1a21d9e5d027ad0d4ec06214a2dc9a21d3c7a6e0..3c99c033a1f6e8dae1bbb84606b160a1efa7184f 100644 (file)
@@ -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
index 43335fe45786ecd2fb45faf3e9c680bed2e9d422..84c3bdf2d8a5a70e469485e4bd009fa01a8e5eb5 100644 (file)
@@ -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':
index a061f77b98cd2fb5f66fd4788a74f99c92e4b269..5a57abff6be8a6670e67ead97f0ecf942b2a8f68 100644 (file)
@@ -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):
index 4d3b69d279e149153ce484435d89ad49826f27dd..1f47d506abde52e57b4e8f986f9c27dd91baab02 100644 (file)
@@ -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)
index 1f9e0b36b159c3afe1d711800fc025b496187934..3e75687ce63f3e87e5dbd4ea4432d0d6529f8814 100644 (file)
@@ -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,