From 788289af4cbe6d288f6dadb9e1eca4ee2740a30d Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 28 Sep 2017 10:01:21 -0500 Subject: Fix Retries for Policies This applies changes to make retries work properly for all control loops. The current design was ignoring the upper bound of the retries and retrying until either a success or control loop timeout occured. This is now fixed to only do retries until the limit is reached that is specified from the policy. The operation is now started in the GUARD.PERMITTED rule. I think this is better because it stops Policy from doing extra processing if there is a guard deny. This is also needed so that we can properly do retries for all cases. The notifications sent in GUARD_NOT_YET_QUERIED and GUARD.RESPONSE are now more informative with the message specifying the actor and recipe. The not queried rule has a message stating that we are sending a query to guard and the guard response message in the guard response rule specifices the result from guard. During a retest of vDNS it appeared that the archetype template was no longer working, this was because there were changes in the JUnit template that were not reflected in the archetype template. These were added to archetype and vDNS is verified to work again. Another small fix needed was making sure the action for vCPE is "Restart" instead of "restart". APPC will reject our request if "Restart" is not sent as the action. Issue-ID: POLICY-259 Change-Id: I28dd3c9a629d297b408775a01afadd5c19351e37 Signed-off-by: Daniel Cruz --- .../controlloop/actor/appc/APPCActorServiceProvider.java | 3 ++- .../actor/appclcm/AppcLcmActorServiceProvider.java | 3 ++- .../actor/appclcm/AppcLcmServiceProviderTest.java | 2 +- .../eventmanager/ControlLoopOperationManager.java | 14 +++++--------- 4 files changed, 10 insertions(+), 12 deletions(-) (limited to 'controlloop/common') diff --git a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java index 9e63e467b..75810c01e 100644 --- a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java +++ b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java @@ -94,7 +94,8 @@ public class APPCActorServiceProvider implements Actor { request.CommonHeader = new CommonHeader(); request.CommonHeader.RequestID = onset.requestID; request.CommonHeader.SubRequestID = operation.subRequestId; - request.Action = policy.getRecipe(); + request.Action = policy.getRecipe().substring(0, 1).toUpperCase() + + policy.getRecipe().substring(1); /* * The target vnf-id may not be the same as the source vnf-id diff --git a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java index 9f556fa2e..4ff1c1d2c 100644 --- a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java +++ b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java @@ -232,7 +232,8 @@ public class AppcLcmActorServiceProvider implements Actor { * An action is required for all APPC requests, this will * be the recipe specified in the policy. */ - appcRequest.setAction(policy.getRecipe().toLowerCase()); + appcRequest.setAction(policy.getRecipe().substring(0, 1).toUpperCase() + + policy.getRecipe().substring(1).toLowerCase()); /* * For R1, the payloads will not be required for the Restart, diff --git a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java index f1df440a8..63ecd2ec9 100644 --- a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java +++ b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java @@ -157,7 +157,7 @@ public class AppcLcmServiceProviderTest { /* An action is required and cannot be null */ assertNotNull(appcRequest.getAction()); - assertEquals(appcRequest.getAction(), "restart"); + assertEquals(appcRequest.getAction(), "Restart"); /* Action Identifiers are required and cannot be null */ assertNotNull(appcRequest.getActionIdentifiers()); diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java index e13352ac0..590e32439 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java @@ -346,8 +346,6 @@ public class ControlLoopOperationManager implements Serializable { return null; } else if (response instanceof SOResponse) { SOResponse msoResponse = (SOResponse) response; - - Integer operationAttempt = this.attempts; switch (msoResponse.httpResponseCode) { case 200: @@ -355,7 +353,7 @@ public class ControlLoopOperationManager implements Serializable { // // Consider it as success // - this.completeOperation(operationAttempt, msoResponse.httpResponseCode + " Success", PolicyResult.SUCCESS); + this.completeOperation(this.attempts, msoResponse.httpResponseCode + " Success", PolicyResult.SUCCESS); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } @@ -364,23 +362,21 @@ public class ControlLoopOperationManager implements Serializable { // // Consider it as failure // - this.completeOperation(operationAttempt, msoResponse.httpResponseCode + " Failed", PolicyResult.FAILURE); + this.completeOperation(this.attempts, msoResponse.httpResponseCode + " Failed", PolicyResult.FAILURE); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } - // increment operation attempts for retries - this.attempts += 1; return PolicyResult.FAILURE; } } else if (response instanceof VFCResponse) { VFCResponse vfcResponse = (VFCResponse) response; - Integer operationAttempt = this.attempts; + if (vfcResponse.responseDescriptor.getStatus().equalsIgnoreCase("finished")) { // // Consider it as success // - this.completeOperation(operationAttempt, " Success", PolicyResult.SUCCESS); + this.completeOperation(this.attempts, " Success", PolicyResult.SUCCESS); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } @@ -389,7 +385,7 @@ public class ControlLoopOperationManager implements Serializable { // // Consider it as failure // - this.completeOperation(operationAttempt, " Failed", PolicyResult.FAILURE); + this.completeOperation(this.attempts, " Failed", PolicyResult.FAILURE); if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { return null; } -- cgit 1.2.3-korg