From: Terry Wilson Date: Fri, 24 Jan 2014 19:04:18 +0000 (-0600) Subject: Ensure ovsdb-client is stopped when OVS agent dies X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=460be872da1dc603abecd4ce988b6c1622996d28;p=openstack-build%2Fneutron-build.git Ensure ovsdb-client is stopped when OVS agent dies 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 --- diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index ed67a67da..2f5934a6a 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -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... "))