ovs-agent: Close ryu app on all exceptions

Previous patch closes app only when ovs-agent raises an exception. This
leaves some corner cases where exceptions inheriting from BaseException
are raised. It's better to be defensive and always close app on error.

Change-Id: Icaaaecc4d00e3a280c3af2e403499bb7ac9e8aa6
Related-bug: 1611237
This commit is contained in:
Jakub Libosvar 2016-11-25 08:15:43 -05:00
parent b8347e16d1
commit 949bce960d
1 changed files with 6 additions and 5 deletions

View File

@ -42,11 +42,12 @@ def agent_main_wrapper(bridge_classes):
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
# it suicides and ends prematurely.
hub.spawn(app_manager.AppManager.get_instance().close)
finally:
# 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
# it suicides and ends prematurely.
hub.spawn(app_manager.AppManager.get_instance().close)
class OVSNeutronAgentRyuApp(app_manager.RyuApp):