From 69a0c6b10e5a85371c1549ff36934c04a1ae1991 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Fri, 24 Jan 2014 13:04:18 -0600 Subject: [PATCH] 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 --- neutron/plugins/openvswitch/agent/ovs_neutron_agent.py | 6 ++++++ 1 file changed, 6 insertions(+) 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... ")) -- 2.45.2