[ONOS-7161] Flows stuck on pending_add after bring the link down
Change-Id: I8281b7cf9348056687ab9e30416170739d22953e
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/installer/FlowRuleIntentInstaller.java b/core/net/src/main/java/org/onosproject/net/intent/impl/installer/FlowRuleIntentInstaller.java
index 0cdd01d..8217255 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/installer/FlowRuleIntentInstaller.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/installer/FlowRuleIntentInstaller.java
@@ -120,13 +120,13 @@
flowRulesToInstall = Collections.emptyList();
}
- List<FlowRule> dontUninstall;
+ List<FlowRule> flowRuleToModify;
List<FlowRule> dontTouch;
// If both uninstall/install list contained equal (=match conditions are equal) FlowRules,
// omit it from remove list, since it will/should be overwritten by install
- dontUninstall = flowRulesToUninstall.stream()
- .filter(flowRule -> flowRulesToInstall.stream().anyMatch(flowRule::equals))
+ flowRuleToModify = flowRulesToInstall.stream()
+ .filter(flowRule -> flowRulesToUninstall.stream().anyMatch(flowRule::equals))
.collect(Collectors.toList());
// If both contained exactMatch-ing FlowRules, remove from both list,
@@ -135,11 +135,13 @@
.filter(flowRule -> flowRulesToUninstall.stream().anyMatch(flowRule::exactMatch))
.collect(Collectors.toList());
- flowRulesToUninstall.removeAll(dontUninstall);
+ flowRulesToUninstall.removeAll(flowRuleToModify);
flowRulesToUninstall.removeAll(dontTouch);
+ flowRulesToInstall.removeAll(flowRuleToModify);
flowRulesToInstall.removeAll(dontTouch);
+ flowRuleToModify.removeAll(dontTouch);
- if (flowRulesToInstall.isEmpty() && flowRulesToUninstall.isEmpty()) {
+ if (flowRulesToInstall.isEmpty() && flowRulesToUninstall.isEmpty() && flowRuleToModify.isEmpty()) {
// There is no flow rules to install/uninstall
intentInstallCoordinator.intentInstallSuccess(context);
return;
@@ -148,6 +150,8 @@
FlowRuleOperations.Builder builder = FlowRuleOperations.builder();
// Add flows
flowRulesToInstall.forEach(builder::add);
+ // Modify flows
+ flowRuleToModify.forEach(builder::modify);
// Remove flows
flowRulesToUninstall.forEach(builder::remove);