Fix a race condition bug when deleting flows: if there are lots of flows
installed, the ONOS instance that received the deleteAll API call
will delete them from the database.
However, while the events are propagated to the other ONOS instances,
the "head" ONOS instance might re-add those flows to the database.
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
index 90ee60a..c502591 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowManager.java
@@ -581,16 +581,6 @@
for (FlowPath flowPath : modifiedFlowPaths) {
//
- // Don't push Flow Paths that are deleted by the user.
- // Those will be deleted at the ONOS instance that received the
- // API call to delete the flow.
- //
- if (flowPath.flowPathUserState() ==
- FlowPathUserState.FP_USER_DELETE) {
- continue;
- }
-
- //
// Push the changes only on the instance responsible for the
// first switch.
//
@@ -600,6 +590,27 @@
continue;
//
+ // Delete the Flow Path from the Network Map
+ //
+ if (flowPath.flowPathUserState() ==
+ FlowPathUserState.FP_USER_DELETE) {
+ log.debug("Deleting Flow Path From Database: {}",
+ flowPath.toString());
+
+ try {
+ if (! FlowDatabaseOperation.deleteFlow(
+ dbHandlerInner,
+ flowPath.flowId())) {
+ log.error("Cannot delete Flow Path {} from Network Map",
+ flowPath.flowId());
+ }
+ } catch (Exception e) {
+ log.error("Exception deleting Flow Path from Network MAP: {}", e);
+ }
+ continue;
+ }
+
+ //
// Test whether all Flow Entries are valid
//
boolean allValid = true;