Fix for [ONOS-5825]
Changes:
- Adds exception management in the mgr;
- Improve logging of the clean up;
Change-Id: I3ca94761e5b4550b7f8df34e9de4a481bc546be3
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
index bb180c8..73b6708 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentCleanup.java
@@ -213,6 +213,8 @@
// Check the pending map first, because the check of the current map
// will add items to the pending map.
for (IntentData intentData : store.getPendingData(true, periodMs)) {
+ log.debug("Resubmit Pending Intent: key {}, state {}, request {}",
+ intentData.key(), intentData.state(), intentData.request());
resubmitPendingRequest(intentData);
pendingCount++;
}
@@ -220,15 +222,21 @@
for (IntentData intentData : store.getIntentData(true, periodMs)) {
switch (intentData.state()) {
case FAILED:
+ log.debug("Resubmit Failed Intent: key {}, state {}, request {}",
+ intentData.key(), intentData.state(), intentData.request());
resubmitCorrupt(intentData, false);
failedCount++;
break;
case CORRUPT:
+ log.debug("Resubmit Corrupt Intent: key {}, state {}, request {}",
+ intentData.key(), intentData.state(), intentData.request());
resubmitCorrupt(intentData, false);
corruptCount++;
break;
case INSTALLING: //FALLTHROUGH
case WITHDRAWING:
+ log.debug("Resubmit Pending Intent: key {}, state {}, request {}",
+ intentData.key(), intentData.state(), intentData.request());
resubmitPendingRequest(intentData);
stuckCount++;
break;
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
index d939f96..6f2ed13 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/IntentManager.java
@@ -433,9 +433,23 @@
.thenApplyAsync(IntentProcessPhase::process, workerExecutor)
.thenApply(FinalIntentProcessPhase::data)
.exceptionally(e -> {
- //FIXME
- log.warn("Future failed: {}", e);
- return null;
+ // When the future fails, we update the Intent to simulate the failure of
+ // the installation/withdrawal phase and we save in the current map. In
+ // the next round the CleanUp Thread will pick this Intent again.
+ log.warn("Future failed", e);
+ log.warn("Intent {} - state {} - request {}",
+ x.key(), x.state(), x.request());
+ switch (x.state()) {
+ case INSTALL_REQ:
+ case INSTALLING:
+ case WITHDRAW_REQ:
+ case WITHDRAWING:
+ x.setState(FAILED);
+ IntentData current = store.getIntentData(x.key());
+ return new IntentData(x, current.installables());
+ default:
+ return null;
+ }
}))
.collect(Collectors.toList());
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
index 5d12e04..9da2e39 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java
@@ -292,11 +292,9 @@
currentMap.put(newData.key(), new IntentData(newData));
}
}
- /*
- * Remove the intent data from the pending map if the newData is more
- * recent or equal to the existing entry. No matter if it is an acceptable
- * update or not.
- */
+ // Remove the intent data from the pending map if the newData is more
+ // recent or equal to the existing entry. No matter if it is an acceptable
+ // update or not
pendingMap.compute(newData.key(), (key, existingValue) -> {
if (existingValue == null || !existingValue.version().isNewerThan(newData.version())) {
return null;