From: FrancescoFioraEst Date: Thu, 28 Nov 2024 14:54:21 +0000 (+0000) Subject: Fix validation in ACM-runtime X-Git-Tag: 8.1.0~8 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=4e99849bef97bdc98f96fd62668ab4f83aa25c7a;p=policy%2Fclamp.git Fix validation in ACM-runtime Fix validation after migration fail and undeploy fail in ACM-runtime. Add more information in fail validation. Issue-ID: POLICY-5195 Change-Id: I870fd31b59bb65db8cb6e8e1b9ee502fc3d63743 Signed-off-by: FrancescoFioraEst --- diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java index 9239b3ae9..09f1b09cd 100644 --- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java +++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java @@ -100,19 +100,12 @@ public class AcInstanceStateResolver { DEPLOYED, LOCKED, SUB_STATE_NONE, NO_ERROR}, MIGRATE_PRECHECK); // make an order in a failed scenario - this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE, - UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, DEPLOY); - this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE, - DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, DEPLOY); - - this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, - UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, UNDEPLOY); + setAllowed(DEPLOY); + setAllowed(UNDEPLOY); this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, UPDATING, LOCKED, SUB_STATE_NONE, FAILED}, UNDEPLOY); this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, MIGRATING, LOCKED, SUB_STATE_NONE, FAILED}, UNDEPLOY); - this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, - DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, UNDEPLOY); this.graph.put(new String[] {DELETE, LOCK_NONE, SUB_NONE, DELETING, LOCK_NONE, SUB_STATE_NONE, FAILED}, DELETE); @@ -131,23 +124,12 @@ public class AcInstanceStateResolver { DEPLOYED, LOCKED, MIGRATION_PRECHECKING, FAILED}, MIGRATE_PRECHECK); // timeout - this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE, - UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, DEPLOY); - this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE, - DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, DEPLOY); - - this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, - UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY); - this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, - UNDEPLOYING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY); this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, UPDATING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY); this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, MIGRATING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY); this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, MIGRATION_PRECHECKING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY); - this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE, - DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY); this.graph.put(new String[] {DELETE, LOCK_NONE, SUB_NONE, DELETING, LOCK_NONE, SUB_STATE_NONE, TIMEOUT}, DELETE); @@ -168,6 +150,28 @@ public class AcInstanceStateResolver { DEPLOYED, LOCKED, MIGRATION_PRECHECKING, TIMEOUT}, MIGRATE_PRECHECK); } + private void setAllowed(String deployOrder) { + this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE, + UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, deployOrder); + this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE, + UNDEPLOYING, LOCKED, SUB_STATE_NONE, FAILED}, deployOrder); + + this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE, + UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, deployOrder); + this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE, + UNDEPLOYING, LOCKED, SUB_STATE_NONE, TIMEOUT}, deployOrder); + + this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE, + DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, deployOrder); + this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE, + DEPLOYING, LOCKED, SUB_STATE_NONE, FAILED}, deployOrder); + + this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE, + DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, deployOrder); + this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE, + DEPLOYING, LOCKED, SUB_STATE_NONE, TIMEOUT}, deployOrder); + } + /** * Check if Deploy Order and Lock Order are consistent with current DeployState and LockState. * diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java index 42af70596..0979a811b 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java @@ -68,6 +68,8 @@ import org.springframework.transaction.annotation.Transactional; public class AutomationCompositionInstantiationProvider { private static final String DO_NOT_MATCH = " do not match with "; private static final String ELEMENT_ID_NOT_PRESENT = "Element id not present "; + private static final String NOT_VALID_ORDER = + "Not valid order %s; DeployState: %s; LockState: %s; SubState: %s; StateChangeResult: %s"; private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionInstantiationProvider.class); @@ -472,7 +474,10 @@ public class AutomationCompositionInstantiationProvider { break; default: - throw new PfModelRuntimeException(Status.BAD_REQUEST, "Not valid " + acInstanceStateUpdate); + var msg = String.format(NOT_VALID_ORDER, acInstanceStateUpdate, + automationComposition.getDeployState(), automationComposition.getLockState(), + automationComposition.getSubState(), automationComposition.getStateChangeResult()); + throw new PfModelRuntimeException(Status.BAD_REQUEST, msg); } } }