diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-01-03 22:50:11 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-01-04 09:15:22 -0500 |
commit | f49313bb87e0dc2ee20f5621c6858d119e5f8f83 (patch) | |
tree | ba1902c3f1ee2f5aa54f75ebe533d58d07755ba5 /bpmn/so-bpmn-tasks/src/main | |
parent | a5bb70becba912f172615b873c4921a2a88dcf3e (diff) |
Bugfixes for December 2018
Changed the way that the cidr is constructed in network utils.
added in the if statement to check if selflink already exists
removed execution line that was not needed in pull
added service instance id to workflowResourceIds for virtualLinkKey
network flows
wrote test for updating request to complete in db
workflow action directly updates db instead of using mso complete
process
Increase max timeout for SDNO Health Checks dmaap.
Added execution variable and corrected type and way data is retrieved
to fix defect
fixed retry status message in request db for #/5
updated workflowActionBBTasks for flow status message
updated flow status to failed on a workflowaction fail
Removed slashes and fixed rollbackStatusMessage
Updated requestStatus logic for adding status messages
Added junit test to validate casue of a defect and cleaned up code and
logging
added end timestamp to request db on complete request
fixed l3Network update of orchestation status in
DoUpdateNetworkInstance groovy as well
fixed update of l3network orchestration status
Add explicit resetting of heatStackId in A&AI to DeleteVfModule and
DeleteVolumeGroup BBs.
Preserve heatStackId setting in the copiedVfModule when updating the VF
Module in A&AI.
added functionality to skip rollback based on flag
Update snapshot version for logging, add headers
fixed optional of error in retrieveErrorMessage method
Set heatStackId to null if we want to remove it in A&AI.
added in a warn logger statement to keep track of field
map network technology from l3network instead of model info for network
adapter object mapper
Force heatStackId value to empty on an attempt to set it to null on
update
updated common pom to use aai schema version 1.4.1
removed handle sync error from SDNCHandler bpmn flow
Change-Id: I1bd7aa55b06d4e439000b216165c9daafeacc9a4
Issue-ID: SO-1361
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
7 files changed, 153 insertions, 32 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 38261c0f1a..ed6379a6a4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -156,7 +156,9 @@ public class AAIUpdateTasks { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); String heatStackId = execution.getVariable("heatStackId"); - + if (heatStackId == null) { + heatStackId = ""; + } VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); CloudRegion cloudRegion = gBBInput.getCloudRegion(); volumeGroup.setHeatStackId(heatStackId); @@ -320,6 +322,9 @@ public class AAIUpdateTasks { public void updateHeatStackIdVfModule(BuildingBlockExecution execution) { try { String heatStackId = execution.getVariable("heatStackId"); + if (heatStackId == null) { + heatStackId = ""; + } VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); vfModule.setHeatStackId(heatStackId); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java index 4506699ce8..81ebfb1f41 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java @@ -75,7 +75,9 @@ public class SDNCQueryTasks { + genericVnf.getVnfId() + "/vnf-data/vf-modules/vf-module/" + vfModule.getVfModuleId() + "/vf-module-data/vf-module-topology/"; try { - vfModule.setSelflink(selfLink); + if(vfModule.getSelflink() == null || (vfModule.getSelflink() != null && vfModule.getSelflink().isEmpty())) { + vfModule.setSelflink(selfLink); + } if(vfModule.getSelflink() != null && !vfModule.getSelflink().isEmpty()) { String response = sdncVfModuleResources.queryVfModule(vfModule); execution.setVariable("SDNCQueryResponse_" + vfModule.getVfModuleId(), response); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java index 58c6db109c..173d5f7e73 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.exception.MapperException; @@ -90,11 +91,6 @@ public class SDNCRequestTasks { public void handleTimeOutException (DelegateExecution execution) { exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error timed out waiting on SDNC Async-Response"); } - - public void handleSyncError (DelegateExecution execution) { - String msg = (String) execution.getVariable("SDNCSyncError"); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); - } protected boolean convertIndicatorToBoolean(String finalMessageIndicator) { return "Y".equals(finalMessageIndicator); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index e04043a352..10ee13ebed 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -166,6 +166,13 @@ public class WorkflowAction { } catch (Exception ex) { cloudOwner = environment.getProperty(defaultCloudOwner); } + boolean suppressRollback = false; + try{ + suppressRollback = requestDetails.getRequestInfo().getSuppressRollback(); + } catch (Exception ex) { + suppressRollback = false; + } + execution.setVariable("suppressRollback", suppressRollback); Resource resource = extractResourceIdAndTypeFromUri(uri); WorkflowType resourceType = resource.getResourceType(); execution.setVariable("resourceName", resourceType.toString()); @@ -401,6 +408,7 @@ public class WorkflowAction { if(virtualLinkKey != null && ebb.getBuildingBlock().getIsVirtualLink() && virtualLinkKey.equalsIgnoreCase(ebb.getBuildingBlock().getVirtualLinkKey())) { WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId(serviceInstanceId); workflowResourceIds.setNetworkId(resourceId); ebb.setWorkflowResourceIds(workflowResourceIds); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java index 7e6eb2a23d..ac06818e66 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java @@ -100,7 +100,7 @@ public class WorkflowActionBBFailure { } catch (Exception ex) { logger.error("Failed to extract workflow exception from execution.",ex); } - return Optional.of(errorMsg); + return Optional.empty(); } public void updateRequestStatusToFailedWithRollback(DelegateExecution execution) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index d9125e4104..917039b17b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -20,7 +20,9 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Optional; @@ -181,27 +183,30 @@ public class WorkflowActionBBTasks { } } - public void setupCompleteMsoProcess(DelegateExecution execution) { - final String requestId = (String) execution.getVariable(G_REQUEST_ID); - final String action = (String) execution.getVariable(G_ACTION); - final String resourceId = (String) execution.getVariable("resourceId"); - final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); - final String resourceName = (String) execution.getVariable("resourceName"); - final String source = (String) execution.getVariable("source"); - String macroAction = ""; - if (aLaCarte) { - macroAction = "ALaCarte-" + resourceName + "-" + action; - } else { - macroAction = "Macro-" + resourceName + "-" + action; + public void updateRequestStatusToComplete(DelegateExecution execution) { + try{ + final String requestId = (String) execution.getVariable(G_REQUEST_ID); + InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + final String action = (String) execution.getVariable(G_ACTION); + final boolean aLaCarte = (boolean) execution.getVariable(G_ALACARTE); + final String resourceName = (String) execution.getVariable("resourceName"); + String macroAction = ""; + if (aLaCarte) { + macroAction = "ALaCarte-" + resourceName + "-" + action + " request was executed correctly."; + } else { + macroAction = "Macro-" + resourceName + "-" + action + " request was executed correctly."; + } + execution.setVariable("finalStatusMessage", macroAction); + Timestamp endTime = new Timestamp(System.currentTimeMillis()); + request.setEndTime(endTime); + request.setStatusMessage(macroAction); + request.setProgress(Long.valueOf(100)); + request.setRequestStatus("COMPLETE"); + request.setLastModifiedBy("CamundaBPMN"); + requestDbclient.updateInfraActiveRequests(request); + }catch (Exception ex) { + workflowAction.buildAndThrowException(execution, "Error Updating Request Database", ex); } - String msoCompletionRequest = "<aetgt:MsoCompletionRequest xmlns:aetgt=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns=\"http://org.onap/so/request/types/v1\"><request-info xmlns=\"http://org.onap/so/infra/vnf-request/v1\"><request-id>" - + requestId + "</request-id><action>" + action + "</action><source>" + source - + "</source></request-info><status-message>" + macroAction - + " request was executed correctly.</status-message><serviceInstanceId>" + resourceId - + "</serviceInstanceId><mso-bpel-name>WorkflowActionBB</mso-bpel-name></aetgt:MsoCompletionRequest>"; - execution.setVariable("CompleteMsoProcessRequest", msoCompletionRequest); - execution.setVariable("mso-request-id", requestId); - execution.setVariable("mso-service-instance-id", resourceId); } public void checkRetryStatus(DelegateExecution execution) { @@ -209,11 +214,12 @@ public class WorkflowActionBBTasks { String requestId = (String) execution.getVariable(G_REQUEST_ID); String retryDuration = (String) execution.getVariable("RetryDuration"); int retryCount = (int) execution.getVariable(RETRY_COUNT); + int nextCount = retryCount +1; if (handlingCode.equals("Retry")){ workflowActionBBFailure.updateRequestErrorStatusMessage(execution); try{ InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); - request.setRetryStatusMessage("Retry " + retryCount+1 + "/5 will be started in " + retryDuration); + request.setRetryStatusMessage("Retry " + nextCount + "/5 will be started in " + retryDuration); requestDbclient.updateInfraActiveRequests(request); } catch(Exception ex){ logger.warn("Failed to update Request Db Infra Active Requests with Retry Status",ex); @@ -221,7 +227,7 @@ public class WorkflowActionBBTasks { if(retryCount<5){ int currSequence = (int) execution.getVariable("gCurrentSequence"); execution.setVariable("gCurrentSequence", currSequence-1); - execution.setVariable(RETRY_COUNT, retryCount + 1); + execution.setVariable(RETRY_COUNT, nextCount); }else{ workflowAction.buildAndThrowException(execution, "Exceeded maximum retries. Ending flow with status Abort"); } @@ -285,4 +291,100 @@ public class WorkflowActionBBTasks { workflowAction.buildAndThrowException(execution, "Rollback has already been called. Cannot rollback a request that is currently in the rollback state."); } } + + protected void updateRequestErrorStatusMessage(DelegateExecution execution) { + try { + String requestId = (String) execution.getVariable(G_REQUEST_ID); + InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + String errorMsg = retrieveErrorMessage(execution); + if(errorMsg == null || errorMsg.equals("")){ + errorMsg = "Failed to determine error message"; + } + request.setStatusMessage(errorMsg); + logger.debug("Updating RequestDB to failed: errorMsg = " + errorMsg); + requestDbclient.updateInfraActiveRequests(request); + } catch (Exception e) { + logger.error("Failed to update Request db with the status message after retry or rollback has been initialized.",e); + } + } + + public void abortCallErrorHandling(DelegateExecution execution) { + String msg = "Flow has failed. Rainy day handler has decided to abort the process."; + logger.error(msg); + throw new BpmnError(msg); + } + + public void updateRequestStatusToFailed(DelegateExecution execution) { + try { + String requestId = (String) execution.getVariable(G_REQUEST_ID); + InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + String errorMsg = null; + String rollbackErrorMsg = null; + boolean rollbackCompleted = (boolean) execution.getVariable("isRollbackComplete"); + boolean isRollbackFailure = (boolean) execution.getVariable("isRollback"); + ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock"); + + if(rollbackCompleted){ + rollbackErrorMsg = "Rollback has been completed successfully."; + request.setRollbackStatusMessage(rollbackErrorMsg); + logger.debug("Updating RequestDB to failed: Rollback has been completed successfully"); + }else{ + if(isRollbackFailure){ + rollbackErrorMsg = retrieveErrorMessage(execution); + if(rollbackErrorMsg == null || rollbackErrorMsg.equals("")){ + rollbackErrorMsg = "Failed to determine rollback error message."; + } + request.setRollbackStatusMessage(rollbackErrorMsg); + logger.debug("Updating RequestDB to failed: rollbackErrorMsg = " + rollbackErrorMsg); + }else{ + errorMsg = retrieveErrorMessage(execution); + if(errorMsg == null || errorMsg.equals("")){ + errorMsg = "Failed to determine error message"; + } + request.setStatusMessage(errorMsg); + logger.debug("Updating RequestDB to failed: errorMsg = " + errorMsg); + } + } + if(ebb!=null && ebb.getBuildingBlock()!=null){ + String flowStatus = ebb.getBuildingBlock().getBpmnFlowName() + " has failed."; + request.setFlowStatus(flowStatus); + execution.setVariable("flowStatus", flowStatus); + } + + request.setProgress(Long.valueOf(100)); + request.setRequestStatus("FAILED"); + request.setLastModifiedBy("CamundaBPMN"); + requestDbclient.updateInfraActiveRequests(request); + } catch (Exception e) { + workflowAction.buildAndThrowException(execution, "Error Updating Request Database", e); + } + } + + private String retrieveErrorMessage (DelegateExecution execution){ + String errorMsg = ""; + try { + WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException"); + if(exception != null && (exception.getErrorMessage()!=null || !exception.getErrorMessage().equals(""))){ + errorMsg = exception.getErrorMessage(); + } + } catch (Exception ex) { + //log error and attempt to extact WorkflowExceptionMessage + logger.error("Failed to extract workflow exception from execution.",ex); + } + + if (errorMsg == null || errorMsg.equals("")){ + try { + errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage"); + } catch (Exception ex) { + logger.error("Failed to extract workflow exception message from WorkflowException",ex); + errorMsg = "Unexpected Error in BPMN."; + } + } + return errorMsg; + } + + public void updateRequestStatusToFailedWithRollback(DelegateExecution execution) { + execution.setVariable("isRollbackComplete", true); + updateRequestStatusToFailed(execution); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index 57c760b01f..4abb0a1b2c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -49,9 +49,12 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; import org.onap.so.entity.MsoRequest; +import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.NetworkRollback; import org.onap.so.openstack.beans.RouteTarget; import org.onap.so.openstack.beans.Subnet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.springframework.web.util.UriUtils; @@ -59,6 +62,7 @@ import org.springframework.web.util.UriUtils; public class NetworkAdapterObjectMapper { private static final ModelMapper modelMapper = new ModelMapper(); private static String FORWARD_SLASH = "/"; + private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterObjectMapper.class); public CreateNetworkRequest createNetworkRequestMapper(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, L3Network l3Network, Map<String, String> userInput, String cloudRegionPo, Customer customer) throws UnsupportedEncodingException { CreateNetworkRequest createNetworkRequest = new CreateNetworkRequest(); @@ -82,8 +86,12 @@ public class NetworkAdapterObjectMapper { //build and set provider Vlan Network ProviderVlanNetwork providerVlanNetwork = buildProviderVlanNetwork(l3Network); createNetworkRequest.setProviderVlanNetwork(providerVlanNetwork); - - createNetworkRequest.setNetworkTechnology(setNetworkTechnology(l3Network.getModelInfoNetwork().getNetworkTechnology())); + String networkTechnology = l3Network.getModelInfoNetwork().getNetworkTechnology(); + if(networkTechnology == null) { + networkTechnology = l3Network.getNetworkTechnology(); + logger.warn("NetworkTechnology was null in CatalogDB. Using field from AAI: " + networkTechnology); + } + createNetworkRequest.setNetworkTechnology(setNetworkTechnology(networkTechnology)); //build and set Contrail Network ContrailNetwork contrailNetwork = buildContrailNetwork(l3Network, customer); |