Protect prepare_update_replace() with resource lock
When we consolidated resource locking with resource state transitions in
a7376f7494b310e9367ebe5dcb43b432a4053023, prepare_update_replace() moved
outside of the locked section, so that other update operations could
potentially conflict with it. This change ensures that we call it while the
lock is still held (if we have transitioned the resource to
UPDATE_IN_PROGRESS, and thus acquired the lock), or that we acquire the
lock before calling it (if UpdateReplace is raised before attempting to
update the resource).
To avoid unnecessary locking and unlocking, we only take the lock if the
Resource plugin has overridden the default handler method (either
restore_prev_rsrc() or prepare_for_replace()), since the defaults do
nothing.
Reviewed: https:/ /review. openstack. org/516459 /git.openstack. org/cgit/ openstack/ heat/commit/ ?id=b0e18270b4a f43452d6c2e229a a76db7ff120980
Committed: https:/
Submitter: Zuul
Branch: master
commit b0e18270b4af434 52d6c2e229aa76d b7ff120980
Author: Zane Bitter <email address hidden>
Date: Mon Oct 30 17:07:12 2017 -0400
Protect prepare_ update_ replace( ) with resource lock
When we consolidated resource locking with resource state transitions in 310e9367ebe5dcb 43b432a4053023, prepare_ update_ replace( ) moved IN_PROGRESS, and thus acquired the lock), or that we acquire the
a7376f7494b
outside of the locked section, so that other update operations could
potentially conflict with it. This change ensures that we call it while the
lock is still held (if we have transitioned the resource to
UPDATE_
lock before calling it (if UpdateReplace is raised before attempting to
update the resource).
To avoid unnecessary locking and unlocking, we only take the lock if the prev_rsrc( ) or prepare_ for_replace( )), since the defaults do
Resource plugin has overridden the default handler method (either
restore_
nothing.
Change-Id: Ie32836ed643e44 0143bde8b83aeb4 d6159acd034
Closes-Bug: #1727127