Resource.has_interface can fail if there are registry changes on update

Bug #1509880 reported by Steve Baker
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Steve Baker
Kilo
Fix Released
Undecided
Unassigned

Bug Description

This happens in templates which have some neutron resources (any one which checks for implicit dependencies, such as OS::Neutron::Port) and when there is a change in the resource registry type names during a stack update.

$ cat base.yaml
heat_template_version: 2014-10-16
parameters:
  network:
    type: string
    default: private
resources:
  port:
    type: OS::Neutron::Port
    properties:
      network: {get_param: network}
  foo:
    type: My::Foo

$ cat env.yaml
resource_registry:
  My::Foo: foo.yaml

$ cat foo.yaml
heat_template_version: 2014-10-16

$ heat stack-create -f base.yaml -e env.yaml a
# wait for complete, edit base.yaml and env.yaml to rename My::Foo to My::Bar

$ heat stack-update -f base.yaml -e env.yaml a
# stack remains IN_PROGRESS forever, the following trace is logged

Oct 26 11:24:23 steveb-dellserver heat-engine[32576]: existing_deps = self.existing_stack.dependencies
Oct 26 11:24:23 steveb-dellserver heat-engine[32576]: File "/usr/lib/python2.7/site-packages/heat/engine/stack.py", line 241, in dependencies
Oct 26 11:24:23 steveb-dellserver heat-engine[32576]: self.resources.itervalues())
Oct 26 11:24:23 steveb-dellserver heat-engine[32576]: File "/usr/lib/python2.7/site-packages/heat/engine/stack.py", line 313, in _get_dependencies
Oct 26 11:24:23 steveb-dellserver heat-engine[32576]: res.add_dependencies(deps)
Oct 26 11:24:23 steveb-dellserver heat-engine[32576]: File "/usr/lib/python2.7/site-packages/heat/engine/resources/openstack/neutron/port.py", line 263, in add_dependencies
Oct 26 11:24:23 steveb-dellserver heat-engine[32576]: if res.has_interface('OS::Neutron::Subnet'):
Oct 26 11:24:23 steveb-dellserver heat-engine[32576]: File "/usr/lib/python2.7/site-packages/heat/engine/resource.py", line 319, in has_interface
Oct 26 11:24:23 steveb-dellserver heat-engine[32576]: return ri.name == resource_type
Oct 26 11:24:23 steveb-dellserver heat-engine[32576]: AttributeError: 'NoneType' object has no attribute 'name'

When the registry changes, get_resource_info might return None, so has_interface needs a None check

Changed in heat:
status: New → Triaged
importance: Undecided → High
assignee: nobody → Steve Baker (steve-stevebaker)
milestone: none → mitaka-1
tags: added: liberty-backport-potential
tags: added: kilo-backport-potential
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/239368

Changed in heat:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/239368
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=af3355d34c8b8e4030f7a928a6c7cb9ad70e0795
Submitter: Jenkins
Branch: master

commit af3355d34c8b8e4030f7a928a6c7cb9ad70e0795
Author: Steve Baker <email address hidden>
Date: Mon Oct 26 17:04:47 2015 +0900

    Resource.has_interface check get_resource_info result

    This changes the behaviour of has_interface to not assume that
    get_resource_info always returns a type. There are circumstances when it
    won't, such as when the type is no longer in the new registry during a
    stack update.

    Change-Id: Idd9dade85d105dc6839ff0740e6c80aca6b7ad9f
    Closes-Bug: #1509880

Changed in heat:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (stable/liberty)

Fix proposed to branch: stable/liberty
Review: https://review.openstack.org/242275

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (stable/kilo)

Fix proposed to branch: stable/kilo
Review: https://review.openstack.org/242276

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (stable/liberty)

Reviewed: https://review.openstack.org/242275
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=070384bc901dc9357a1e099ef8c8b5c053a7eb69
Submitter: Jenkins
Branch: stable/liberty

commit 070384bc901dc9357a1e099ef8c8b5c053a7eb69
Author: Steve Baker <email address hidden>
Date: Mon Oct 26 17:04:47 2015 +0900

    Resource.has_interface check get_resource_info result

    This changes the behaviour of has_interface to not assume that
    get_resource_info always returns a type. There are circumstances when it
    won't, such as when the type is no longer in the new registry during a
    stack update.

    Change-Id: Idd9dade85d105dc6839ff0740e6c80aca6b7ad9f
    Closes-Bug: #1509880
    (cherry picked from commit af3355d34c8b8e4030f7a928a6c7cb9ad70e0795)

tags: added: in-stable-liberty
tags: removed: liberty-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (stable/kilo)

Reviewed: https://review.openstack.org/242276
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=cf60e32d208d776831329c057c5ccd156d423ee5
Submitter: Jenkins
Branch: stable/kilo

commit cf60e32d208d776831329c057c5ccd156d423ee5
Author: Steve Baker <email address hidden>
Date: Mon Oct 26 17:04:47 2015 +0900

    Resource.has_interface check get_resource_info result

    This changes the behaviour of has_interface to not assume that
    get_resource_info always returns a type. There are circumstances when it
    won't, such as when the type is no longer in the new registry during a
    stack update.

    Change-Id: Idd9dade85d105dc6839ff0740e6c80aca6b7ad9f
    Closes-Bug: #1509880
    (cherry picked from commit af3355d34c8b8e4030f7a928a6c7cb9ad70e0795)

tags: added: in-stable-kilo
Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/heat 6.0.0.0b1

This issue was fixed in the openstack/heat 6.0.0.0b1 development milestone.

Changed in heat:
status: Fix Committed → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/heat 5.0.1

This issue was fixed in the openstack/heat 5.0.1 release.

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.