From a13a5737cde4f81e51a2f939f77fdd35d8ab483e Mon Sep 17 00:00:00 2001 From: Dan Wendlandt Date: Thu, 20 Sep 2012 21:49:51 -0700 Subject: [PATCH] Add catch-call try/catch within rpc_loop in ovs plugin agent related to bug 1050512 when running in db-mode, the ovs plugin agent will catch any unexpected exceptions generated during processing. However, in rpc-mode, this does not happen, meaning a small error, even a transient one, causes the agent to exit completely. Thic change adds a try-catch block to the rcp_loop(), causing the agent to log any unexpected exception, wait for the polling period, then retry the loop after resetting all state. Change-Id: I76eae1800831e59c5078c4be8fa5ca22298bfb0a --- .../openvswitch/agent/ovs_quantum_agent.py | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py index 2cc219ab7..c488e8240 100755 --- a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py +++ b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py @@ -744,25 +744,31 @@ class OVSQuantumAgent(object): tunnel_sync = True while True: - start = time.time() - if sync: - LOG.info("Agent out of sync with plugin!") - ports.clear() - sync = False - - # Notify the plugin of tunnel IP - if self.enable_tunneling and tunnel_sync: - LOG.info("Agent tunnel out of sync with plugin!") - tunnel_sync = self.tunnel_sync() - - port_info = self.update_ports(ports) - - # notify plugin about port deltas - if port_info: - LOG.debug("Agent loop has new devices!") - # If treat devices fails - indicates must resync with plugin - sync = self.process_network_ports(port_info) - ports = port_info['current'] + try: + start = time.time() + if sync: + LOG.info("Agent out of sync with plugin!") + ports.clear() + sync = False + + # Notify the plugin of tunnel IP + if self.enable_tunneling and tunnel_sync: + LOG.info("Agent tunnel out of sync with plugin!") + tunnel_sync = self.tunnel_sync() + + port_info = self.update_ports(ports) + + # notify plugin about port deltas + if port_info: + LOG.debug("Agent loop has new devices!") + # If treat devices fails - must resync with plugin + sync = self.process_network_ports(port_info) + ports = port_info['current'] + + except: + LOG.exception("Error in agent event loop") + sync = True + tunnel_sync = True # sleep till end of polling interval elapsed = (time.time() - start) -- 2.45.2