Remote exception from nested stack can break all future exceptions of that type

Bug #1474153 reported by Zane Bitter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Critical
Angus Salkeld
Kilo
Fix Released
Critical
Steve Baker

Bug Description

The change at line 282 here:

https://review.openstack.org/#/c/116336/38/heat/engine/resources/stack_resource.py

uses the copy module to make a copy of an exception class, and then modifies instance variables of the local 'copy':

  local_ex = copy.copy(getattr(exception, ex_type))
 local_ex.msg_fmt = "%(message)s"
 raise local_ex(message=message)

THIS DOES NOT MAKE A COPY. To wit:

  >>> import copy
  >>> class A(Exception):
  ... msg_fmt = 'foo'
  ...
  >>>
  >>> B = copy.copy(A)
  >>> B.msg_fmt = 'bar'
  >>> A.msg_fmt
  'bar'
  >>> B is A
  True

As a result, once the engine has received a remote exception from this code, all future exceptions of this type will have the wrong formatting string, likely causing them to fail if they take different keyword arguments. (It's something of a mystery why we haven't seen a failure of this type reported.)

Zane Bitter (zaneb)
no longer affects: heat/liberty
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/201389

Changed in heat:
status: New → In Progress
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/201391

Changed in heat:
assignee: Zane Bitter (zaneb) → Angus Salkeld (asalkeld)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

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

commit 716471f37c04216c10546e30f72888a49a79c05e
Author: Angus Salkeld <email address hidden>
Date: Tue Jul 14 11:52:42 2015 +1000

    Don't copy exception classes

    see:
    http://stackoverflow.com/questions/9541025/how-to-copy-a-python-class
    https://review.openstack.org/194487

    This simplifies the method so it just re-raises local exceptions
    and if it is Remote, raises ResourceFailure.

    Closes-Bug: #1474153

    Change-Id: I9c4dcadcbcf6abe6ff71dbcdccaae4706b684a83

Changed in heat:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on heat (master)

Change abandoned by Zane Bitter (<email address hidden>) on branch: master
Review: https://review.openstack.org/201389
Reason: We merged I9c4dcadcbcf6abe6ff71dbcdccaae4706b684a83 instead.

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/202333

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

Change abandoned by Zane Bitter (<email address hidden>) on branch: stable/kilo
Review: https://review.openstack.org/201391
Reason: Abandoned in favour of backporting I9c4dcadcbcf6abe6ff71dbcdccaae4706b684a83.

Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (stable/kilo)

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

commit 7e73da580f932e657b3f029338c5c62eee69a0cb
Author: Angus Salkeld <email address hidden>
Date: Tue Jul 14 11:52:42 2015 +1000

    Don't copy exception classes

    see:
    http://stackoverflow.com/questions/9541025/how-to-copy-a-python-class
    https://review.openstack.org/194487

    This simplifies the method so it just re-raises local exceptions
    and if it is Remote, raises ResourceFailure.

    Closes-Bug: #1474153

    Change-Id: I9c4dcadcbcf6abe6ff71dbcdccaae4706b684a83
    (cherry-picked from commit 716471f37c04216c10546e30f72888a49a79c05e)

tags: added: in-stable-kilo
removed: kilo-backport-potential
Thierry Carrez (ttx)
Changed in heat:
milestone: liberty-2 → 5.0.0
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.