Brief introduction
Example of scenario with a deployed instance with two element:
- user call undeploy command
- first instance element success with UNDEPLOYED state
- second instance element fail with DEPLOYED state
- user call undeploy command again
- first instance element does not know that the element is already UNDEPLOYED
Add support for the participant to understand what was the last state.
Additional comments
It is important to make distinction between the state of the instance/element in the flow, and the state of the application involved. A deployed element means that a participant has completed a deploy action, and should not be confused with a deployed application.
In the example there are scenarios where it make sense when a process is failed, all elements should be repeat fully, by in other scenarios could de different, it depend of the context.
Solutions
A simple solution from participant side is that they can to use "useState" or "operationalState" to save information related to the deployment process.
Into the participant implementation they can send by sendAcElementInfo method.
To support that implementation we can add "useState" or "operationalState" into the InstanceElementDto:
public record InstanceElementDto(UUID instanceId, UUID elementId, ToscaServiceTemplate toscaServiceTemplateFragment, Map<String, Object> inProperties, Map<String, Object> outProperties, String operationalState, String useState) { }
Below an example how could be used:
@Override public void deploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException { if (DeployState.DEPLOYED.toString().equals(instanceElement.useState())) { // deploy process already done } ....................................... ....................................... intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), "", "DEPLOYED", instanceElement.outProperties()); } @Override public void undeploy(CompositionElementDto compositionElement, InstanceElementDto instanceElement) throws PfModelException { if (DeployState.UNDEPLOYED.toString().equals(instanceElement.useState())) { // undeploy process already done } ....................................... ....................................... intermediaryApi.sendAcElementInfo(instanceElement.instanceId(), instanceElement.elementId(), "", "UNDEPLOYED", instanceElement.outProperties()); }