Some intrinsic functions fail when referencing get_attr

Bug #1559807 reported by Dan Prince
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Triaged
Medium
Rico Lin

Bug Description

The following sample stack fails:

heat_template_version: 2016-04-08

parameters:
  ControllerServices:
    default:
      - OS::TripleO::Services::Keystone
    type: comma_delimited_list

resources:

  GoldChain:
    type: OS::Heat::ResourceChain
    properties:
      resources: {get_param: ControllerServices}
      resource_properties:
        Foo: bar

  Controller:
    type: OS::Heat::ResourceGroup
    depends_on: GoldChain
    properties:
      count: 1
      resource_def:
        type: foo.yaml
        properties:
          Foo: {map_merge: {get_attr: [GoldChain, role_data, config_settings]}}

----

The error messages shows up as: ERROR: Property error: : resources.Controller.properties.resource_def: : Incorrect arguments to "map_merge" should be: "map_merge" : [ { "key1": "val1" }, { "key2": "val2" } ]

----

I've tried a similar stack and skipping the resource group and instead doing the same merge_map in an output and it seems to work fine.

Steven Hardy (shardy)
Changed in heat:
assignee: nobody → Steven Hardy (shardy)
tags: added: tripleo
Revision history for this message
Steven Hardy (shardy) wrote : Re: map_merge fails to merge resource chains in a resource_group definition

Looks like this is a bug in the map_merge implementation, we need to handle referenced to functions at the validate stage, both referencing a list and each item in the list referencing a function.

summary: - merge_map fails to merge resource chains in a resource_group definition
+ map_merge fails to merge resource chains in a resource_group definition
Changed in heat:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Steven Hardy (shardy) wrote :

Looks like this is a bug in the map_merge implementation, we need to handle referenced to functions at the validate stage, both referencing a list and each item in the list referencing a function, working on a patch.

Revision history for this message
Steven Hardy (shardy) wrote :

So, after further investigation, this is actually a much more general problem.

Basically get_attr returns None in the case where a resource is not yet created:

https://github.com/openstack/heat/blob/master/heat/engine/hot/functions.py#L163

Which then breaks the value validation when we validate properties that indirectly reference get_attr via an intrinsic function that validates the data it's passed (because we actually call the function "result" function, not only "validate" when we validate, because of this call:

https://github.com/openstack/heat/blob/master/heat/engine/resource.py#L1333

Essentially the strict_validate (which turns on value validation for properties, which triggers the call to get the function result), is enabled for all non-nested stacks, so we're trying to resolve the functions too early in those cases.

I'm not sure of the cleanest solution - there are several functions where "None" isn't a valid input, so perhaps we should never validate values at the resource.validate_template stage.

Revision history for this message
Steven Hardy (shardy) wrote :

Another example which shows breakage unrelated to map_merge or ResourceGroup:

heat_template_version: 2016-04-08
resources:
  foo:
    type: foo_list.yaml

  server:
    type: OS::Nova::Server
    properties:
      image: cirros-0.3.4-x86_64-uec
      flavor: m1.small
      metadata:
        # Neither of these work, fail with validation errors
        map_merge: {get_attr: [foo, foo]}
        foo: {list_join: {get_attr: [foo, foo]}}

foo_list.yaml is:

heat_template_version: 2015-04-30
outputs:
  foo:
    value: [{"foo": 123}]

summary: - map_merge fails to merge resource chains in a resource_group definition
+ Some intrinsic functions fail when referencing get_attr
Revision history for this message
Steven Hardy (shardy) wrote :

I think that preview updates are broken for the same reason, we compare the bfore/after properties and the previewed stack attributes are all None.

Revision history for this message
Steven Hardy (shardy) wrote :

ML thread started looking for additional input on this:

http://lists.openstack.org/pipermail/openstack-dev/2016-March/090241.html

Revision history for this message
Rico Lin (rico-lin) wrote :

As discussed in newton summit https://etherpad.openstack.org/p/heat-newton-validation-improvements
We possibly go with place holder for further solving this issue.
I'm now digging on this and test on some poc develop for this isse.

Rico Lin (rico-lin)
tags: added: heat-validate
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/387463

Changed in heat:
assignee: Steven Hardy (shardy) → Rico Lin (rico-lin)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/387464

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/387465

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/387466

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/387467

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/387468

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/387469

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/387470

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/387471

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/387472

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Fix proposed to branch: master
Review: https://review.openstack.org/387473

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on heat (master)

Change abandoned by Rico Lin (<email address hidden>) on branch: master
Review: https://review.openstack.org/387465
Reason: Just a test patch, not going to be final solution

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Rico Lin (<email address hidden>) on branch: master
Review: https://review.openstack.org/387463
Reason: Just a test patch, not going to be final solution

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Rico Lin (<email address hidden>) on branch: master
Review: https://review.openstack.org/387467
Reason: Just a test patch, not going to be final solution

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Rico Lin (<email address hidden>) on branch: master
Review: https://review.openstack.org/387469
Reason: Just a test patch, not going to be final solution

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Rico Lin (<email address hidden>) on branch: master
Review: https://review.openstack.org/387470
Reason: Just a test patch, not going to be final solution

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Rico Lin (<email address hidden>) on branch: master
Review: https://review.openstack.org/387471
Reason: Just a test patch, not going to be final solution

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Rico Lin (<email address hidden>) on branch: master
Review: https://review.openstack.org/387473
Reason: Just a test patch, not going to be final solution

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Rico Lin (<email address hidden>) on branch: master
Review: https://review.openstack.org/387466
Reason: Just a test patch, not going to be final solution

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Rico Lin (<email address hidden>) on branch: master
Review: https://review.openstack.org/387468
Reason: Just a test patch, not going to be final solution

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Rico Lin (<email address hidden>) on branch: master
Review: https://review.openstack.org/387472

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Rico Lin (<email address hidden>) on branch: master
Review: https://review.openstack.org/387464

Rico Lin (rico-lin)
Changed in heat:
milestone: none → queens-1
Rico Lin (rico-lin)
Changed in heat:
milestone: queens-1 → queens-2
Zane Bitter (zaneb)
Changed in heat:
status: In Progress → Triaged
Rico Lin (rico-lin)
Changed in heat:
milestone: queens-2 → queens-3
Rico Lin (rico-lin)
Changed in heat:
milestone: queens-3 → rocky-1
Rico Lin (rico-lin)
Changed in heat:
milestone: rocky-1 → rocky-2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.