Flows under io.cloudslang.base.os.linux are failing on: 'bool_value' should have a String value
Closed this issue · 2 comments
Hi,
I'm working on a flow that is supposed to install tomcat on a RHEL server. I tried to reuse the io.cloudslang.base.os.linux.samples.deploy_tomcat_on_gentoo flow.
When running it, I realized that certain sub-flows (see below) fail on this error:
SEVERE: Command failed java.lang.RuntimeException: Slang Error: Error running: evaluate_result: Error binding step input: 'bool_value' should have a String value.
Generally speaking, the failing flows are the ones containing this step:
- evaluate_result:
do:
utils.is_true:
- bool_value: ${return_code == '0' and command_return_code == '0'}
navigate:
- 'TRUE': SUCCESS
- 'FALSE': FAILURE
Those flows are located in io.cloudslang.base.os.linux folder and sub-folders.
It seems that the bool_value is missing str() conversion; after I changed it into:
- bool_value: str(${return_code == '0' and command_return_code == '0'})
...it slightly helped. Now, the flow gets executed but with FAILURE result. This is the cmd-line output when the group does not exist:
- verify_if_group_exist
- - validate_ssh_access
- - ssh_command
- evaluate_result
Flow outputs:
- command_return_code = 1
- message = The "tomcat" group does not exist.
- return_code = 0
Flow: verify_group_exist finished with result: FAILURE
And when the group exists:
- verify_if_group_exist
- - validate_ssh_access
- - ssh_command
- evaluate_result
Flow outputs:
- return_result = tomcat
- command_return_code = 0
- message = The "tomcat" group exist.
- return_code = 0
- standard_out = tomcat
Flow: verify_group_exist finished with result: FAILURE
Please note the command_return_code is evaluated to different values (1, 0) when the group does not exist / does exist.
According the the logs, it seems the str() conversion helped; however, the internal condition (return_code == '0' and command_return_code == '0') did not get evaluated and thus is not equal to 'TRUE'.
IMHO, there are 2 additional issues in the flow.
- command_return_code should be always 0 (even when the group does not exist)
- the internal condition must get evaluated even when enclosed into str() conversion function -> it does not get evaluated now.
Please, let me know how to alter the flow to make it SUCCEEDED.
Please note, I'm using CLI 1.0.0 (downloaded from https://github.com/CloudSlang/cloud-slang/releases/download/cloudslang-1.0.0/cslang-cli-with-content.zip)
you are right @pe-pan , the expression return values for CS 1.0 must be strings, since ${}
marks a CS expression - the correct syntax would be:
${str( return_code == '0' and command_return_code == '0' )}
about the return code, please note difference between them:
#! @output command_return_code: The return code of the remote command corresponding to the SSH channel. The return code is
#! only available for certain types of channels, and only after the channel was closed
#! (more exactly, just before the channel is closed).
#! Examples: '0' for a successful command, '-1' if the command was not yet terminated (or this
#! channel type has no command), '126' if the command cannot execute.
#! @output return_code: return code of the command
in other words, return code is usually 0 if no exception occurs during the action, whereas the command_return_code is the exit code of bash (0 for successful execution... etc)
please let us know how it goes
Thanks @Bonczidai; works for me. This is the change fixing the bug: e9a40d2b2eb69d3fcd9ad57aa350ce5f7f6bd642