]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add catch-call try/catch within rpc_loop in ovs plugin agent
authorDan Wendlandt <dan@nicira.com>
Fri, 21 Sep 2012 04:49:51 +0000 (21:49 -0700)
committerDan Wendlandt <dan@nicira.com>
Fri, 21 Sep 2012 04:49:51 +0000 (21:49 -0700)
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

quantum/plugins/openvswitch/agent/ovs_quantum_agent.py

index 2cc219ab7c3a4ca5aeb5e21697577d01104c84bd..c488e824041587746c75411c151f999906e0f659 100755 (executable)
@@ -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)