Can't use conditions with depends_on
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Heat |
Fix Released
|
Medium
|
Thomas Herve |
Bug Description
Trying to use conditional resource creation breaks any serialization via depends_on:
[stack@instack ~]$ heat stack-create tx -f test_conditions
ERROR: The specified reference "two" (in three) is incorrect.
[stack@instack ~]$ cat test_conditions
heat_template_
parameters:
a_param:
type: string
default: ''
conditions:
a_param_
not:
equals:
- get_param: a_param
- ''
resources:
one:
type: OS::Heat:
two:
depends_on: one
condition: a_param_
type: OS::Heat:
three:
depends_on: two
type: OS::Heat:
It would be good if we could simply figure out the implicit dependency between "three" and "one" in this case, and make the depends_on via two a pass-through when a_param_
Trying to work around it by using the "if" function in depends_on doesn't work either:
stack@instack ~]$ heat stack-create tx -f test_conditions
ERROR: Resource three depends_on type must be list or string
[stack@instack ~]$ cat test_conditions
heat_template_
parameters:
a_param:
type: string
default: ''
conditions:
a_param_
not:
equals:
- get_param: a_param
- ''
resources:
one:
type: OS::Heat:
two:
depends_on: one
condition: a_param_
type: OS::Heat:
three:
depends_on:
if:
- a_param_
- two
- one
type: OS::Heat:
Changed in heat: | |
assignee: | nobody → huangtianhua (huangtianhua) |
Changed in heat: | |
milestone: | none → ocata-3 |
Changed in heat: | |
assignee: | huangtianhua (huangtianhua) → Thomas Herve (therve) |
Changed in heat: | |
importance: | Undecided → Critical |
importance: | Critical → Medium |
It's an interesting problem to solve. To me, the first template is not the same as the second, because passthrough isn't the logical behavior to have when a condition is not met. If three depends on two, and two is not created, three shouldn't be created either.
I think it's worth trying to see if we can make the second template work. In the meantime, you should be able to workaround by defining three twice:
three: is_not_ empty}
depends_on: one
condition: {not: a_param_
three_2: is_not_ empty
depends_on: two
condition: a_param_