This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
SWITCH task should COMPLETE after decision cases are done #3271
Labels
Comments
Hello @sebimal I tested the above workflow, and the issue I saw is that the switch task is evaluated to |
1 task
This is same happening to me. Is there any fix associated to this or workaround |
I used SUB_WORKFLOW to wrap SWITCH with all of its branched behaviour. Workarround for my previous example: {
"name": "ADHoc-loop-test",
"version": 1,
"input": {
"list": [
{
"number": 1
},
{
"number": 2
},
{
"number": 3
}
]
},
"workflowDef": {
"name": "ADHoc-loop-test",
"description": "Program for testing loop behaviour",
"version": 1,
"schemaVersion": 2,
"ownerEmail": "xyz@company.eu",
"tasks": [
{
"name": "LoopTask",
"taskReferenceName": "LoopTask",
"type": "DO_WHILE",
"inputParameters": {
"list": "${workflow.input.list}"
},
"loopCondition": "$.LoopTask['iteration'] < $.list.length",
"loopOver": [
{
"name": "GetNumberAtIndex",
"taskReferenceName": "GetNumberAtIndex",
"type": "INLINE",
"inputParameters": {
"evaluatorType": "javascript",
"list": "${workflow.input.list}",
"iterator": "${LoopTask.output.iteration}",
"expression": "function getElement() { return $.list.get($.iterator - 1); } getElement();"
}
},
{
"name": "SwitchSubWorkflow",
"taskReferenceName": "SwitchSubWorkflow",
"type": "SUB_WORKFLOW",
"inputParameters": {
"param": "${GetNumberAtIndex.output.result.number}"
},
"subWorkflowParam": {
"name": "SwitchWrapper",
"version": 1,
"workflowDefinition": {
"name": "SwitchWrapper",
"version": 1,
"ownerEmail": "xyz@company.eu",
"tasks": [
{
"name": "SwitchTask",
"taskReferenceName": "SwitchTask",
"type": "SWITCH",
"evaluatorType": "javascript",
"inputParameters": {
"param": "${workflow.input.param}"
},
"expression": "$.param > 0",
"decisionCases": {
"true": [
{
"name": "WaitTask",
"taskReferenceName": "WaitTask",
"type": "WAIT",
"inputParameters": {
"duration": "10 secs"
}
},
{
"name": "ComputeNumber",
"taskReferenceName": "ComputeNumber",
"type": "INLINE",
"inputParameters": {
"evaluatorType": "javascript",
"number": "${workflow.input.param}",
"expression": "function compute() { return $.number+10; } compute();"
}
}
]
}
}
]
}
}
}
]
}
]
}
} |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What bothers me
SWITCH task is marked as COMPLETEd immediately after processing expression. With this behaviour it is dangerous to use it in DO_WHILE task, where every iteration is marked as completed (and next one is started) when every task from loopTasks are completed. Similar problem shows for FORK_JOIN where JOIN task has SWITCH in joinOn section but does not wait for it's decision cases.
Example
As an example you may run following workflow
From above execution I expect to process every
number
sequentially but the third one is processed three times instead.Expected behavior
It would be great if SWITCH task completed after all of its decisionCases and defaultCase are finished.
The text was updated successfully, but these errors were encountered: