Lock detach_volume
A detach_volume operation may take place during a attach_volume or
delete_instance opertaion. This may lead to a race condition which
would result in an instance going into an error state as the volume
operation is not atomic.
Commit 4c4dc3a6d
added the lock around the attach_volume. This
follows that same pattern.
Co-Authored-By: Matthew Booth <mbooth@redhat.com>
Change-Id: I7261135a44f0c2eca4732c8360b9c74b729991a8
Closes-bug: #1662483
This commit is contained in:
parent
ee57c92e8b
commit
2e4e203c1a
|
@ -5633,10 +5633,14 @@ class ComputeManager(manager.Manager):
|
|||
and volume.
|
||||
|
||||
"""
|
||||
bdm = objects.BlockDeviceMapping.get_by_volume_and_instance(
|
||||
context, volume_id, instance.uuid)
|
||||
self._detach_volume(context, bdm, instance,
|
||||
attachment_id=attachment_id)
|
||||
@utils.synchronized(instance.uuid)
|
||||
def do_detach_volume(context, volume_id, instance, attachment_id):
|
||||
bdm = objects.BlockDeviceMapping.get_by_volume_and_instance(
|
||||
context, volume_id, instance.uuid)
|
||||
self._detach_volume(context, bdm, instance,
|
||||
attachment_id=attachment_id)
|
||||
|
||||
do_detach_volume(context, volume_id, instance, attachment_id)
|
||||
|
||||
def _init_volume_connection(self, context, new_volume,
|
||||
old_volume_id, connector, bdm,
|
||||
|
|
Loading…
Reference in New Issue