or condition doesn't behave as expected

18 views
Skip to first unread message

Eitan Yanovsky

unread,
Dec 10, 2013, 9:42:00 AM12/10/13
to openwfe...@googlegroups.com
Hi,

I am using radial and I am experiencing a very odd behavior, consider the following workflow:

define or_condition
    echo 'start ${f:node.host_id}'
    sequence if: '${f:node.host_id} is not set'
        echo 'is not set'
    sequence if: '${f:node.host_id} is set'
        echo 'is set'
    sequence if: '${f:node.host_id} == ${f:node.id}'
        echo '=='
    sequence if: '${f:node.host_id} is not set or ${f:node.host_id} == ${f:node.id}'
        echo 'or'

the field which is set is 'node' which is a map that contains only 'id' property:
I get the following output:

start 
is not set

I do not get the 'echo or' part which doesn't make sense as I do get the 'is not set' output in the 1st condition.
This means that the 1st condition is met, as expected, but the 4th condition is not met even though it is an or statement between condition 1 and 2.
I tried adding brackets to each of the condition in the or statement but it didn't help.

I also tried converting the or into and and not (using demorgan transformation logic) and it didn't help.
I can try nested if but I wish to avoid this workarounds and understand why this doesn't work as expected.

Please advise.

Thanks


John Mettraux

unread,
Dec 10, 2013, 5:02:28 PM12/10/13
to openwfe...@googlegroups.com

On Tue, Dec 10, 2013 at 06:42:00AM -0800, Eitan Yanovsky wrote:
>
> I also tried converting the or into and and not (using demorgan
> transformation logic) and it didn't help.
> I can try nested if but I wish to avoid this workarounds and understand why
> this doesn't work as expected.

Hello,

I'm sorry that's a limitation of the "is [not] set", "is [not] empty" set of
tools. I've always meant to go for something better but haven't found the
time. They're meant to be used standalone (not with an "or" or an "and").

I guess the nested way is OK.


Sorry again,

--
John Mettraux - http://lambda.io/jmettraux

Eitan Yanovsky

unread,
Dec 11, 2013, 10:54:55 AM12/11/13
to openwfe...@googlegroups.com
I see, I actually didn't do this with nested as I am not sure how to convert this to nested sequence if condition due to the following reason:
I have condition A or B, if I switch to nested it means changing it to 'and' so it needs to be not (not A and not B).
I don't know how to handle the external not in a nested if.
Instead I did the following workaround, I will be glad to hear if someone has a better idea:

define or_condition
            set 'v:no_host_id': "false"
            set 'v:is_host_node': "false"
            sequence if: '${f:node.host_id} is not set'
                set 'v:no_host_id': "true"
            sequence if: '${f:node.host_id} == ${f:node.id}'
                set 'v:is_host_node': "true"
            sequence if: '${v:no_host_id} or ${v:is_host_node}'
                yada yada....
Reply all
Reply to author
Forward
0 new messages