From 82e396d6917519468376d177dd6a2710e84fa23a Mon Sep 17 00:00:00 2001 From: Julien Fontaine Date: Tue, 27 Jul 2021 12:43:24 -0400 Subject: Removed redundant timeout handling for executeCommand executeCommand was called from a GlobalScope.async coroutine to handle executeCommand timeout. Execution timeout is already handled on the gRPC side, there's no need to handle this timeout by wrapping the gRPC call with a coroutine timeout. When a lot of long running processes in executeCommand were running, it was causing process to queue on BP side to get their executeCommand executed because all the capacity of couroutines were being used by some long running process. This was causing a delay on the execution of prepareEnv and executeCommand and would even some time make those process timeout because of component timeout. Issue-ID: CCSDK-3386 Signed-off-by: Julien Fontaine Change-Id: If3aef4b6b65006e874525436bf3f6d1b1a3d8c9a --- .../executor/ComponentRemotePythonExecutor.kt | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'ms') diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt index 539e03dc8..5f6d98fd2 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt +++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt @@ -19,10 +19,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.python.executor import com.fasterxml.jackson.databind.JsonNode import com.google.protobuf.ByteString -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.TimeoutCancellationException -import kotlinx.coroutines.async -import kotlinx.coroutines.withTimeout import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertiesService import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.PrepareRemoteEnvInput @@ -205,13 +201,7 @@ open class ComponentRemotePythonExecutor( timeOut = executionTimeout.toLong() ) - val remoteExecutionOutputDeferred = GlobalScope.async { - remoteScriptExecutionService.executeCommand(remoteExecutionInput) - } - - val remoteExecutionOutput = withTimeout(executionTimeout * 1000L + TIMEOUT_DELTA) { - remoteExecutionOutputDeferred.await() - } + val remoteExecutionOutput = remoteScriptExecutionService.executeCommand(remoteExecutionInput) checkNotNull(remoteExecutionOutput) { "Error: Request-id $processId did not return a result from remote command execution." @@ -226,17 +216,11 @@ open class ComponentRemotePythonExecutor( } else { setNodeOutputProperties(remoteExecutionOutput.status, STEP_EXEC_CMD, logs, returnedPayload, isLogResponseEnabled) } // In timeout exception cases, we don't have payload, hence `payload` is empty value. - } catch (timeoutEx: TimeoutCancellationException) { + } catch (grpcEx: io.grpc.StatusRuntimeException) { val componentLevelWarningMsg = if (timeout < executionTimeout) "Note: component-level timeout ($timeout) is shorter than execution timeout ($executionTimeout). " else "" val timeoutErrMsg = - "Command executor execution timeout. DetailedMessage: (${timeoutEx.message}) requestId ($processId). $componentLevelWarningMsg" - setNodeOutputErrors(STEP_EXEC_CMD, listOf(timeoutErrMsg).asJsonType(), logging = isLogResponseEnabled) - addError(StatusType.FAILURE.name, STEP_EXEC_CMD, timeoutErrMsg) - log.error(timeoutErrMsg, timeoutEx) - } catch (grpcEx: io.grpc.StatusRuntimeException) { - val timeoutErrMsg = - "Command executor timed out executing after $executionTimeout seconds requestId ($processId) grpcErr: ${grpcEx.status}" + "Command executor timed out executing after $executionTimeout seconds requestId ($processId). $componentLevelWarningMsg grpcErr: ${grpcEx.status}" setNodeOutputErrors(STEP_EXEC_CMD, listOf(timeoutErrMsg).asJsonType(), logging = isLogResponseEnabled) addError(StatusType.FAILURE.name, STEP_EXEC_CMD, timeoutErrMsg) log.error(timeoutErrMsg, grpcEx) -- cgit 1.2.3-korg