From b96b44d6d7ca11dbbc3ad4bd2194df31fba5efb6 Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Wed, 9 Dec 2020 19:49:48 -0500 Subject: Refactoring to enable on_failure for imperative workflow BlueprintError needs to associate errors with the steps in which they occurred in order for imperative workflow to handle on_failure properly. Made stepName more accessible and corrected places where stepName was assigned to nodeTemplateName. Issue-ID: CCSDK-3219 Change-Id: I7e5805745c63558cff6be533e1b99c32ad06c3db Signed-off-by: Jozsef Csongvai --- .../resource/resolution/ResourceResolutionComponent.kt | 5 +++-- .../resource/resolution/ResourceResolutionService.kt | 15 ++++++++------- .../capabilities/IpAssignResolutionCapability.kt | 2 +- .../resolution/capabilities/NamingResolutionCapability.kt | 2 +- .../processor/CapabilityResourceResolutionProcessor.kt | 3 +-- .../processor/DatabaseResourceAssignmentProcessor.kt | 2 +- .../processor/DefaultResourceResolutionProcessor.kt | 2 +- .../processor/InputResourceResolutionProcessor.kt | 2 +- .../resolution/processor/ResourceAssignmentProcessor.kt | 4 ++-- .../processor/RestResourceResolutionProcessor.kt | 2 +- .../resolution/ResourceResolutionComponentTest.kt | 5 +++-- .../resource/resolution/ResourceResolutionServiceTest.kt | 3 ++- .../mock/MockRestResourceResolutionProcessor.kt | 2 +- 13 files changed, 26 insertions(+), 23 deletions(-) (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src') diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt index 6a2e128e2..ada1a720e 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt @@ -115,7 +115,8 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re bluePrintRuntimeService, nodeTemplateName, artifactPrefixNames, - properties + properties, + stepName ) // provide indexed result in output if we have multiple resolution @@ -140,6 +141,6 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { - bluePrintRuntimeService.getBlueprintError().addError(runtimeException.message!!) + addError(runtimeException.message!!) } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt index 46410a859..ea420dca4 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt @@ -65,7 +65,8 @@ interface ResourceResolutionService { bluePrintRuntimeService: BlueprintRuntimeService<*>, nodeTemplateName: String, artifactNames: List, - properties: Map + properties: Map, + stepName: String ): ResourceResolutionResult suspend fun resolveResources( @@ -128,7 +129,8 @@ open class ResourceResolutionServiceImpl( bluePrintRuntimeService: BlueprintRuntimeService<*>, nodeTemplateName: String, artifactNames: List, - properties: Map + properties: Map, + stepName: String ): ResourceResolutionResult { val resourceAssignmentRuntimeService = @@ -150,11 +152,10 @@ open class ResourceResolutionServiceImpl( val failedResolution = resourceAssignmentList.filter { it.status != "success" && it.property?.required == true }.map { it.name } if (failedResolution.isNotEmpty()) { - // The following error message is returned by default to handle a scenario when - // error message comes empty even when resolution has actually failed. - // Example: input-source type resolution seems to fail with no error code. - bluePrintRuntimeService.getBlueprintError().errors.add("Failed to resolve required resources($failedResolution)") - bluePrintRuntimeService.getBlueprintError().errors.addAll(resourceAssignmentRuntimeService.getBlueprintError().errors) + val errorMessages = mutableListOf("Failed to resolve required values: $failedResolution").apply { + this.addAll(resourceAssignmentRuntimeService.getBlueprintError().allErrors()) + } + bluePrintRuntimeService.getBlueprintError().addErrors(stepName, errorMessages) } } return ResourceResolutionResult(templateMap, assignmentMap) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt index d9a5ba0d1..a1f3249ab 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/IpAssignResolutionCapability.kt @@ -116,7 +116,7 @@ open class IpAssignResolutionCapability : ResourceAssignmentProcessor() { } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { - raRuntimeService.getBlueprintError().addError(runtimeException.message!!) + addError(runtimeException.message!!) } /** Generates aggregated request payload for Ip Assign mS. Parses the resourceassignments of diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt index 903c1b3fa..4f656a8f0 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/capabilities/NamingResolutionCapability.kt @@ -118,7 +118,7 @@ open class NamingResolutionCapability : ResourceAssignmentProcessor() { } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { - raRuntimeService.getBlueprintError().addError(runtimeException.message!!) + addError(runtimeException.message!!) } /** Generates aggregated request payload for Naming mS. Parses the resourceassignments of diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt index 4f33c8252..5e834d73d 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt @@ -87,8 +87,7 @@ open class CapabilityResourceResolutionProcessor(private var componentFunctionSc } override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { - raRuntimeService.getBlueprintError() - .addError("Failed in CapabilityResourceResolutionProcessor : ${runtimeException.message}") + addError("Failed in CapabilityResourceResolutionProcessor : ${runtimeException.message}") ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, runtimeException.message) } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt index 640b0f5fe..db5307f17 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt @@ -183,6 +183,6 @@ open class DatabaseResourceAssignmentProcessor( } override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { - raRuntimeService.getBlueprintError().addError(runtimeException.message!!) + addError(runtimeException.message!!) } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt index f90a8b5fa..e904ebcb4 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt @@ -64,6 +64,6 @@ open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() { } override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { - raRuntimeService.getBlueprintError().addError(runtimeException.message!!) + addError(runtimeException.message!!) } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt index d85449b19..c3add86fd 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt @@ -91,6 +91,6 @@ open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() { } override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { - raRuntimeService.getBlueprintError().addError(runtimeException.message!!) + addError(runtimeException.message!!) } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt index b5bafad59..ce00ac17b 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt @@ -191,11 +191,11 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode>(), - any>() + any>(), + "step" ) } returns ResourceResolutionResult(mutableMapOf(), mutableMapOf()) @@ -168,7 +169,7 @@ class ResourceResolutionComponentTest { every { bluePrintRuntimeService.getBlueprintError() } returns blueprintError resourceResolutionComponent.recoverNB(exception, executionRequest) - assertEquals(1, blueprintError.errors.size) + assertEquals(1, blueprintError.allErrors().size) } } } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt index 00fb39515..a1de557d5 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt @@ -182,7 +182,8 @@ class ResourceResolutionServiceTest { bluePrintRuntimeService, "resource-assignment", artifactNames, - props + props, + "mockStep" ) }.let { assertEquals(artifactNames.toSet(), it.templateMap.keys) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt index de46fe6f3..77c90ba51 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt @@ -110,7 +110,7 @@ class MockRestResourceResolutionProcessor( } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { - raRuntimeService.getBlueprintError().addError(runtimeException.message!!) + addError(runtimeException.message!!) } private fun blueprintWebClientService(resourceAssignment: ResourceAssignment): MockBlueprintWebClientService { -- cgit 1.2.3-korg