From 3e45c19eedccd800d7c6e5f0fce57295cf3a7b02 Mon Sep 17 00:00:00 2001 From: IWAMOTO Toshihiro Date: Tue, 22 Nov 2016 16:59:54 +0900 Subject: [PATCH] ovs-agent: Catch exceptions in agent_main_wrapper When of_interface=native, the ovs agent code is run as a ryuapp thread, which means it must be properly shut down or the process fails to terminate. Catch exceptions and make sure that the agent terminates, even if in unlucky cases. Change-Id: I7aebeaa00e2416a275d9ecd940eb28c819349656 Closes-Bug: #1611237 --- .../openvswitch/agent/openflow/native/ovs_ryuapp.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_ryuapp.py b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_ryuapp.py index ea22bd7fc72..445c98e78b7 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_ryuapp.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/ovs_ryuapp.py @@ -16,6 +16,7 @@ import functools +from oslo_log import log as logging import ryu.app.ofctl.api # noqa from ryu.base import app_manager from ryu.lib import hub @@ -23,6 +24,7 @@ from ryu.lib import type_desc from ryu.ofproto import ofproto_v1_3 from ryu.ofproto import oxm_fields +from neutron._i18n import _LE from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ import br_int from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ @@ -32,9 +34,14 @@ from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \ from neutron.plugins.ml2.drivers.openvswitch.agent \ import ovs_neutron_agent as ovs_agent +LOG = logging.getLogger(__name__) + def agent_main_wrapper(bridge_classes): - ovs_agent.main(bridge_classes) + try: + ovs_agent.main(bridge_classes) + except Exception: + LOG.exception(_LE("Agent main thread died of an exception")) # The following call terminates Ryu's AppManager.run_apps(), # which is needed for clean shutdown of an agent process. # The close() call must be called in another thread, otherwise