From 6fa084b5591d28dbd984fbd560446ef23aee97f3 Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 9 Aug 2024 20:11:54 +0800 Subject: [PATCH] fix(Pool): sending too long error messages to the Orchestrator - cut off too long error messages - also make the communication more robust for future problems. On an exception the Pool now tries to resolve the tasks with a generic error --- .../service/TaskStepFetchAndReserveService.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveService.kt index 7d03eaf7e..f6cb1a3f7 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveService.kt @@ -69,7 +69,21 @@ class TaskStepFetchAndReserveService( if (taskStepReservation.reservedTasks.isNotEmpty()) { val taskResults = upsertGoldenRecordIntoPool(taskStepReservation.reservedTasks) - orchestrationClient.goldenRecordTasks.resolveStepResults(TaskStepResultRequest(step = TaskStep.PoolSync, results = taskResults)) + + //Limit the length of errors so for the Orchestrator to not reject it + val resultsWithSafeErrors = taskResults.map { result -> + result.copy(errors = result.errors.map { error -> + error.copy(description = error.description.take(250)) + }) + } + try{ + orchestrationClient.goldenRecordTasks.resolveStepResults(TaskStepResultRequest(step = TaskStep.PoolSync, results = resultsWithSafeErrors)) + }catch (e: Throwable){ + logger.error { "Some unexpected problem on the orchestrator side. Try to resolve the current tasks with generic exceptions to at least get them out of the reserved state" } + val genericErrorResults = resultsWithSafeErrors.map { TaskStepResultEntryDto(it.taskId, BusinessPartner.empty, listOf(TaskErrorDto(TaskErrorType.Unspecified, "Unknown exception when communicating with the golden record process"))) } + orchestrationClient.goldenRecordTasks.resolveStepResults(TaskStepResultRequest(step = TaskStep.PoolSync, results = genericErrorResults )) + } + } logger.info { "Cleaning tasks processing completed for this iteration." }