]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Ensure ovsdb-client is stopped when OVS agent dies
authorTerry Wilson <twilson@redhat.com>
Fri, 24 Jan 2014 19:04:18 +0000 (13:04 -0600)
committerThomas Goirand <thomas@goirand.fr>
Thu, 13 Mar 2014 07:20:31 +0000 (15:20 +0800)
If the OVS agent is killed, the interpreter is killed before any cleanup
is done. This patch adds a signal handler for SIGTERM that exits
normally so that the existing cleanup is done and the ovsdb-client
process is terminated.

Change-Id: Ie4f8ff434098100f4699124403d58caa784084cf

neutron/plugins/openvswitch/agent/ovs_neutron_agent.py

index ed67a67daefc8a78eed64a25b299569858ff656d..2f5934a6aaeaf1515f75ecc6b75c7e5390582541 100644 (file)
@@ -23,6 +23,7 @@
 # @author: Kyle Mestery, Cisco Systems, Inc.
 
 import distutils.version as dist_version
+import signal
 import sys
 import time
 
@@ -1253,6 +1254,10 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
             self.rpc_loop(polling_manager=pm)
 
 
+def handle_sigterm(signum, frame):
+    sys.exit(1)
+
+
 def check_ovs_version(min_required_version, root_helper):
     LOG.debug(_("Checking OVS version for VXLAN support"))
     installed_klm_version = ovs_lib.get_installed_ovs_klm_version()
@@ -1351,6 +1356,7 @@ def main():
         cfg.CONF.set_default('ip_lib_force_root', True)
 
     agent = OVSNeutronAgent(**agent_config)
+    signal.signal(signal.SIGTERM, handle_sigterm)
 
     # Start everything.
     LOG.info(_("Agent initialized successfully, now running... "))