aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/python-executor
diff options
context:
space:
mode:
authorJulien Fontaine <julien.fontaine@bell.ca>2020-06-29 19:54:27 -0400
committerJulien Fontaine <julien.fontaine@bell.ca>2020-07-02 15:36:20 +0000
commit01e3ff777b995767311be29ad51ebba53cb054c2 (patch)
tree6906e5c275096ea6834a02fd04fc5c3b9102e563 /ms/blueprintsprocessor/functions/python-executor
parentca17370464f688d3bd5b63de12d9163ef8e31e08 (diff)
Command Executor : Invalid response_data when executed script fails
* Modified command exec returned value in case of failure during execution. It now prints the response_data defined by the user * Modified truncation method of the gRPC returned object to use ByteSize() to get the exact sizxe consumed within the buffer Issue-ID: CCSDK-2501 Signed-off-by: Julien Fontaine <julien.fontaine@bell.ca> Change-Id: Ie1db8db265623b5137ab3946ff4e3abda1c54a78
Diffstat (limited to 'ms/blueprintsprocessor/functions/python-executor')
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt36
1 files changed, 18 insertions, 18 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 50f0b1499..7f32fa95d 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
@@ -182,12 +182,12 @@ open class ComponentRemotePythonExecutor(
val componentLevelWarningMsg = if (timeout < envPrepTimeout) "Note: component-level timeout ($timeout) is shorter than env-prepare timeout ($envPrepTimeout). " else ""
val grpcErrMsg = "Command failed during env. preparation... timeout($envPrepTimeout) requestId ($processId). $componentLevelWarningMsg grpcError: ${grpcEx.status}"
setAttribute(ATTRIBUTE_PREPARE_ENV_LOG, grpcErrMsg.asJsonPrimitive())
- setNodeOutputErrors(status = StatusType.FAILURE.name, step = STEP_PREPARE_ENV, error = grpcErrMsg.asJsonPrimitive(), logging = isLogResponseEnabled)
+ setNodeOutputErrors(status = StatusType.FAILURE.name, step = STEP_PREPARE_ENV, message = grpcErrMsg.asJsonPrimitive(), logging = isLogResponseEnabled)
log.error(grpcErrMsg, grpcEx)
} catch (e: Exception) {
val timeoutErrMsg = "Command executor failed during env. preparation.. catch-all case timeout($envPrepTimeout) requestId ($processId). exception msg: ${e.message}"
setAttribute(ATTRIBUTE_PREPARE_ENV_LOG, e.message.asJsonPrimitive())
- setNodeOutputErrors(status = StatusType.FAILURE.name, step = STEP_PREPARE_ENV, error = timeoutErrMsg.asJsonPrimitive(), logging = isLogResponseEnabled)
+ setNodeOutputErrors(status = StatusType.FAILURE.name, step = STEP_PREPARE_ENV, message = timeoutErrMsg.asJsonPrimitive(), logging = isLogResponseEnabled)
log.error(timeoutErrMsg, e)
}
// if Env preparation was successful, then proceed with command execution in this Env
@@ -236,7 +236,7 @@ open class ComponentRemotePythonExecutor(
setNodeOutputErrors(status = StatusType.FAILURE.name,
step = STEP_EXEC_CMD,
logs = "".asJsonPrimitive(),
- error = timeoutErrMsg.asJsonPrimitive(),
+ message = timeoutErrMsg.asJsonPrimitive(),
logging = isLogResponseEnabled
)
log.error(timeoutErrMsg, timeoutEx)
@@ -245,13 +245,13 @@ open class ComponentRemotePythonExecutor(
setNodeOutputErrors(status = StatusType.FAILURE.name,
step = STEP_EXEC_CMD,
logs = "".asJsonPrimitive(),
- error = timeoutErrMsg.asJsonPrimitive(),
+ message = timeoutErrMsg.asJsonPrimitive(),
logging = isLogResponseEnabled
)
log.error(timeoutErrMsg, grpcEx)
} catch (e: Exception) {
val timeoutErrMsg = "Command executor failed during process catch-all case requestId ($processId) timeout($envPrepTimeout) exception msg: ${e.message}"
- setNodeOutputErrors(status = StatusType.FAILURE.name, step = STEP_PREPARE_ENV, error = timeoutErrMsg.asJsonPrimitive(), logging = isLogResponseEnabled)
+ setNodeOutputErrors(status = StatusType.FAILURE.name, step = STEP_PREPARE_ENV, message = timeoutErrMsg.asJsonPrimitive(), logging = isLogResponseEnabled)
log.error(timeoutErrMsg, e)
}
}
@@ -280,42 +280,42 @@ open class ComponentRemotePythonExecutor(
private fun setNodeOutputProperties(
status: JsonNode = StatusType.FAILURE.name.asJsonPrimitive(),
step: String,
+ logs: JsonNode,
message: JsonNode,
- artifacts: JsonNode,
logging: Boolean = true
) {
setAttribute(ATTRIBUTE_EXEC_CMD_STATUS, status)
- setAttribute(ATTRIBUTE_RESPONSE_DATA, artifacts)
- setAttribute(ATTRIBUTE_EXEC_CMD_LOG, message)
+ setAttribute(ATTRIBUTE_RESPONSE_DATA, message)
+ setAttribute(ATTRIBUTE_EXEC_CMD_LOG, logs)
if (logging) {
- log.info("Executor status : $step : $status")
- log.info("Executor artifacts: $step : $artifacts")
- log.info("Executor message : $step : $message")
+ log.info("Executor status : $step : $status")
+ log.info("Executor message: $step : $message")
+ log.info("Executor logs : $step : $logs")
}
}
/**
- * Utility function to set the output properties and errors of the executor node, in cas of errors
+ * Utility function to set the output properties and errors of the executor node, in case of errors
*/
private fun setNodeOutputErrors(
status: String,
step: String,
logs: JsonNode = "N/A".asJsonPrimitive(),
- error: JsonNode,
+ message: JsonNode,
logging: Boolean = true
) {
setAttribute(ATTRIBUTE_EXEC_CMD_STATUS, status.asJsonPrimitive())
setAttribute(ATTRIBUTE_EXEC_CMD_LOG, logs)
- setAttribute(ATTRIBUTE_RESPONSE_DATA, "N/A".asJsonPrimitive())
+ setAttribute(ATTRIBUTE_RESPONSE_DATA, message)
if (logging) {
- log.info("Executor status : $step : $status")
- log.info("Executor message : $step : $error")
- log.info("Executor logs : $step : $logs")
+ log.info("Executor status : $step : $status")
+ log.info("Executor message: $step : $message")
+ log.info("Executor logs : $step : $logs")
}
- addError(status, step, error.toString())
+ addError(status, step, logs.toString())
}
}