summaryrefslogtreecommitdiffstats
path: root/services/services-onappf/src
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@bell.ca>2022-04-08 16:22:17 +0100
committera.sreekumar <ajith.sreekumar@bell.ca>2022-04-08 16:22:22 +0100
commitc95f74758ccc2aa680bcd7477b10cb47f3b5080e (patch)
treeb9bb3b69b28d6bce62975bcedefe87b5eee7c4bf /services/services-onappf/src
parentd0a0ff83aaeccbb16e92b1f09c0160e84e4f8340 (diff)
Fix wrong APEX-PDP behaviour during state change
When a policy is deployed & undeployed, and then on doing PDP_STATE_CHANGE to passive and then active, previously undeployed policies are taken from memory and tried to be deployed. Any undeployed policies should be cleared from the engine memory. This is fixed here. Change-Id: I8f6fbc64d29bd8d89e906376d0770d375ffd8b82 Issue-ID: POLICY-4087 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
Diffstat (limited to 'services/services-onappf/src')
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
index 1bcb8970b..b8e361e1e 100644
--- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
+++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java
@@ -103,6 +103,7 @@ public class PdpUpdateMessageHandler {
List<ToscaPolicy> policies = Registry.getOrDefault(ApexStarterConstants.REG_APEX_TOSCA_POLICY_LIST,
List.class, new ArrayList<>());
policies.addAll(pdpUpdateMsg.getPoliciesToBeDeployed());
+ policies.removeIf(policy -> pdpUpdateMsg.getPoliciesToBeUndeployed().contains(policy.getIdentifier()));
Set<ToscaConceptIdentifier> policiesInDeployment = policies.stream().map(ToscaPolicy::getIdentifier)
.collect(Collectors.toSet());
policiesInDeployment.removeAll(pdpUpdateMsg.getPoliciesToBeUndeployed());
@@ -118,9 +119,12 @@ public class PdpUpdateMessageHandler {
// if some policy fails, that shouldn't go in the heartbeat.
// If no policies are running, then the policy list in the heartbeat can be empty
if (null != apexEngineHandler && apexEngineHandler.isApexEngineRunning()) {
- pdpStatusContext.setPolicies(apexEngineHandler.getRunningPolicies());
+ var runningPolicies = apexEngineHandler.getRunningPolicies();
+ pdpStatusContext.setPolicies(runningPolicies);
+ policies.removeIf(policy -> !runningPolicies.contains(policy.getIdentifier()));
} else {
pdpStatusContext.setPolicies(Collections.emptyList());
+ policies.clear();
}
}
if (null == pdpResponseDetails) {