diff options
author | Julien Fontaine <julien.fontaine@bell.ca> | 2021-07-27 12:43:24 -0400 |
---|---|---|
committer | Julien Fontaine <julien.fontaine@bell.ca> | 2021-07-27 12:56:17 -0400 |
commit | 82e396d6917519468376d177dd6a2710e84fa23a (patch) | |
tree | dd6313e31e18a7a072e28494b351b503b559ecb7 /ms/blueprintsprocessor/functions/python-executor/src | |
parent | 3fb5e3aa70f26a7cc39b0ee756c97d4490d0bd94 (diff) |
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 <julien.fontaine@bell.ca>
Change-Id: If3aef4b6b65006e874525436bf3f6d1b1a3d8c9a
Diffstat (limited to 'ms/blueprintsprocessor/functions/python-executor/src')
-rw-r--r-- | ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt | 22 |
1 files changed, 3 insertions, 19 deletions
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) |