]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Handle SIGHUP in ovs neutron agent
authorElena Ezhova <eezhova@mirantis.com>
Mon, 1 Jun 2015 11:55:13 +0000 (14:55 +0300)
committerElena Ezhova <eezhova@mirantis.com>
Fri, 5 Jun 2015 07:25:23 +0000 (10:25 +0300)
This change allows ovs neutron agent not to die on receiving SIGHUP
and reload its logging options.

Note that this patch allows changing only logging options.
All other config options are not handled explicitly and changing
them using SIGHUP can lead to unpredictable circumstances.
So, until changing other options is handled it is highly recommended
to use SIGHUP for changing ONLY logging options.

Change-Id: Ic0cf8a9ca7f3a16b556a6825e2979471ae136c33
Partial-Bug: #1276694

neutron/plugins/openvswitch/agent/ovs_neutron_agent.py

index 7673a674bd3c9e58b6bc4228336e714a58802ff2..36e8851fdf58ba83adadb039c21ecbb70c3a6efc 100644 (file)
@@ -14,6 +14,7 @@
 #    under the License.
 
 import hashlib
+import logging as std_logging
 import signal
 import sys
 import time
@@ -33,6 +34,7 @@ from neutron.agent.linux import ip_lib
 from neutron.agent import rpc as agent_rpc
 from neutron.agent import securitygroups_rpc as sg_rpc
 from neutron.api.rpc.handlers import dvr_rpc
+from neutron.common import config
 from neutron.common import constants as q_const
 from neutron.common import exceptions
 from neutron.common import topics
@@ -1591,6 +1593,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         # Start everything.
         LOG.info(_LI("Agent initialized successfully, now running... "))
         signal.signal(signal.SIGTERM, self._handle_sigterm)
+        signal.signal(signal.SIGHUP, self._handle_sighup)
         with polling.get_polling_manager(
             self.minimize_polling,
             self.ovsdb_monitor_respawn_interval) as pm:
@@ -1598,11 +1601,18 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
             self.rpc_loop(polling_manager=pm)
 
     def _handle_sigterm(self, signum, frame):
-        LOG.debug("Agent caught SIGTERM, quitting daemon loop.")
+        LOG.info(_LI("Agent caught SIGTERM, quitting daemon loop."))
         self.run_daemon_loop = False
         if self.quitting_rpc_timeout:
             self.set_rpc_timeout(self.quitting_rpc_timeout)
 
+    def _handle_sighup(self, signum, frame):
+        LOG.info(_LI("Agent caught SIGHUP, resetting."))
+        cfg.CONF.reload_config_files()
+        config.setup_logging()
+        LOG.debug('Full set of CONF:')
+        cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
+
     def set_rpc_timeout(self, timeout):
         for rpc_api in (self.plugin_rpc, self.sg_plugin_rpc,
                         self.dvr_plugin_rpc, self.state_rpc):