Don't delete RawTemplate if it referenced by a stack
When creating a nested stack and pre-storing the raw template, we
previously used a try/finally block to ensure that if the stack creation
was never started (e.g. because the template failed validation at the other
end) that we would delete the raw template again rather than leave it lying
around in the DB. However, this catches too broad a range of exceptions. If
an exception such as GreenletExit occurs inside this block, then we will
attempt to delete the raw template, resulting in a DB IntegrityError either
here (because the template id is already referenced by a stack) or when
trying to store the stack (because the template is gone).
Resolve this by only doing the cleanup on HeatExceptions, which indicates
that the other engine has bailed out without storing the stack.
Reviewed: https:/ /review. openstack. org/374340 /git.openstack. org/cgit/ openstack/ heat/commit/ ?id=55c21c18e64 55515c93f6f6222 e7dd820c45ebd5
Committed: https:/
Submitter: Jenkins
Branch: master
commit 55c21c18e645551 5c93f6f6222e7dd 820c45ebd5
Author: Zane Bitter <email address hidden>
Date: Wed Sep 21 14:57:22 2016 -0400
Don't delete RawTemplate if it referenced by a stack
When creating a nested stack and pre-storing the raw template, we
previously used a try/finally block to ensure that if the stack creation
was never started (e.g. because the template failed validation at the other
end) that we would delete the raw template again rather than leave it lying
around in the DB. However, this catches too broad a range of exceptions. If
an exception such as GreenletExit occurs inside this block, then we will
attempt to delete the raw template, resulting in a DB IntegrityError either
here (because the template id is already referenced by a stack) or when
trying to store the stack (because the template is gone).
Resolve this by only doing the cleanup on HeatExceptions, which indicates
that the other engine has bailed out without storing the stack.
Change-Id: Ie24a82b7ce1628 1c72d4eb66cca86 83248628b46
Closes-Bug: #1626256