Argo workflows: How to check if the output of a previous suspended step has been supplied inside the "when" expression of a subsequent step? - argo-workflows

In an Argo workflow, I have a loop and I need to continue running the loop in case the output of a previous step has NOT been supplied yet. Until now, I couldn't find any way of performing this simple empty/null check. The following "when" expression:
when: "'{{steps.wait-completion.outputs.parameters.result}}' == ''"
never evaluates as expected because Argo returns the tag name as it is (without being substituted) if the value has not been supplied and then I get:
'{{steps.wait-completion.outputs.parameters.result}}' == ''' evaluated false
Is this a bug or a feature? Any ideas how I can perform such a check from the "when" expression? I also tried using the "default" tag to set a default but it seems to be ignored by the suspend step (another bug or another feature?)
I would really appreciate some ideas here. Thanks in advance!
What I tried:
when: "'{{steps.wait-completion.outputs.parameters.result}}' == ''"
What I expected:
When expression above evaluates to true if the output parameter "result" has not been supplied yet.
What I got:
'{{steps.wait-completion.outputs.parameters.result}}' == ''' evaluated false

Related

Until flag not working with Until activity of ADF and loop keep going

I'm trying to execute Azure Durable Function in ADF.
I have "Get Current Function Status" Activity inside Until activity. Possible value are pending, completed, running and exception. I have variable until_flag which do get value "true" if runTimeStatus get value Completed.
My problem is that even runTimeStatus is completed Until loop never stop. It keeps going. What is wrong?
I'm following tutorial https://www.youtube.com/watch?v=aD3k8k5sdao
I have tried:
#equals(bool(variables('until_flag')), 'true')
and
#bool(variables('until_flag'))
If you look into the official MS docs on UntilActivity
Enter an expression that will be evaluated after all child activities
defined in the Until activity are executed. If the expression
evaluates to false, the Until activity will execute all its child
activities again. When it evaluates to true, the Until activity will
complete. The expression can be a literal string expression, or any
combination of dynamic expressions, functions, system variables, or
outputs from other activities.
So try with this expression to evaluate condition
#equals(variables('until_flag'), 'false')

Drools filtering stream within DRL

I would like to create a rule with lamba expression like below:
when
rule_id: String() from "784acba8-32e5-41de-bd73-04f9ce2bfaff"
$: DroolsEventWrapper(Arrays.stream("testing".split("")).filter(element->(element!=null && element.contains("e"))).findFirst().isPresent())
then
System.out.println("Qualified for "+rule_id);
end
just a simple check "testing" will be given as a parameter also; however when I use it drl. It gave error like:
mismatched input '.' in rule "784acba8-32e5-41de-bd73-04f9ce2bfaff" in pattern
When I check the location of that dot; it belongs to filter(element->(element!=null && element.contains("e"))) when I omit it, it is working.
I am using the latest version of Drools: 7.55.0.Final. I found some tickets which say that lambda expressions somehow buggy at previous versions but not the latest ones.
Do I missing something, or is there any way to run this within DRL ?

How to deal with Null for custom condition in Azure Pipeline?

I'm finding the best way to find a variable is null on the custom condition.
I tried to compare null. However, Azure Pipeline complains cause error, if I configure like this.
and(failed(), ne(variables['Some'], Null))
Also, This configuration doesn't throw an error, however, when the 'Some' is null, the condition becomes false. Since Null and 'Null' is different.
and(failed(), ne(variables['Some'], 'Null'))
I eventually come up with a workaround. However, it is not cool way. I add PowerShell task, and create this script.
if ($env:Some -eq $null) {
Write-Host "##vso[task.setvariable variable=SkipSome]True"
}
then configure custom condition
and(failed(), ne(variables['SkipSome'], 'True'))
I expect there is a way to compare with null without the powershell. However, I can't find it on the official documentation.
How to deal with Null for custom condition in Azure Pipeline?
To deal with Null for custom condition, we should use '' instead of Null or 'Null'.
You can check the String for some details.
So, you can configure it like following:
and(failed(), ne(variables['Some'], ''))
To test it more intuitively, I change the ne to eq:
and(failed(), eq(variables['Some'], ''))
Then I set the variable is empty on the Variable tab, and add a Inline powershell task with above condition:
In the log, we could see that task is executed:
Hope this helps.

How to perform a conditional test within a Talend job?

I am looking to trigger a series of processes, and I want to tell if each one succeeds or fails before starting the subsequent ones.
I am using tSSH (on Talend 6.4.1) to trigger a process and I only want the job to continue if it is a success. The tSSH "component" doesn't appear to fail if it receives a non-zero return code, so I have tried using an assert. However, even if the assert fails, it doesn't appear to prevent the component and subjob being "OK" which is a bit odd, so I can't use on-(component|subjob)-ok to link to the next job.
I don't seem to be able to find any conditional evaluation components which will allow me to stop the continuation of the job or subjob based on the evaluation result.
The only way I can find is to have
tSSH1 --IF globalMap.get("tSSH_1_EXIT_CODE").equals(0)--> tSSH2...
--IF !globalMap.get("tSSH_1_EXIT_CODE").equals(0)--> (failure logging subjob)
which means coding the test twice with negation.
Am I missing something, or are there no such conditional components?
you can put a if condition on tSSH component for success /failure using global variable of tSSH component i.e.
((String)globalMap.get("tSSH_1_STDERR")) and ((String)globalMap.get("tSSH_1_STDOUT")).
if condition you can check is :
if(((String)globalMap.get("tSSH_1_STDERR")) != null) than call error log
else call tSSH2.
Hope this helps...

XML Expression Binding - Proceed Code in conditional operator

I am currently working on a Fiori app. At the moment I try to set a title depending on the value of a property I get from my OData service. Therefore I want to use expression binding with the conditional operator.
So when ${PROPERTIY} has the value "EXAMPLE", it should print the value of OUTPUT_PROPERTY_1. Otherwise, it should print the value of OUTPUT_PROPERTY_2.
XML:
<ObjectListItem title="{= ${PROPERTIY} === 'EXAMPLE' ? '${OUTPUT_PROPERTY_1}' : '${OUTPUT_PROPERTY_2}'}">
Unfortunately, it just prints ${OUTPUT_PROPERTY_1} or ${OUTPUT_PROPERTY_2}, and does not proceed the code to get the actual value of the properties.
Is there any chance to solve this problem or even a good workaround in order to print the actual value of the related property?
Remove the apostrophes around the expression binding syntax:
title="{= ${PROPERTIY} === 'EXAMPLE' ? ${OUTPUT_PROPERTY_1} : ${OUTPUT_PROPERTY_2}}"
Otherwise, '${OUTPUT_PROPERTY_x}' will be treated as a string literal.