summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Kotton <gkotton@vmware.com>2019-02-13 09:50:14 -0800
committerChris Dent <cdent@anticdent.org>2019-02-18 12:44:02 +0000
commit17b3d5734af9c7b916cfc7007e98f43df975b8e8 (patch)
tree68c3195b0cc2cd8bf1f13b36f5d69d46232c3384
parent123d0966718b1634b282071965ee25ad88b3ac4f (diff)
Lock detach_volumestable/queens
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 (cherry picked from commit 2e4e203c1a4c4f91dd1aabae8c8d7b745df99be7)
Notes
Notes (review): Code-Review+2: Lee Yarwood <lyarwood@redhat.com> Code-Review+2: Matt Riedemann <mriedem.os@gmail.com> Workflow+1: Matt Riedemann <mriedem.os@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 19 Feb 2019 01:39:52 +0000 Reviewed-on: https://review.openstack.org/637535 Project: openstack/nova Branch: refs/heads/stable/queens
-rw-r--r--nova/compute/manager.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 244ae5b..8c99297 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -5466,10 +5466,14 @@ class ComputeManager(manager.Manager):
5466 and volume. 5466 and volume.
5467 5467
5468 """ 5468 """
5469 bdm = objects.BlockDeviceMapping.get_by_volume_and_instance( 5469 @utils.synchronized(instance.uuid)
5470 context, volume_id, instance.uuid) 5470 def do_detach_volume(context, volume_id, instance, attachment_id):
5471 self._detach_volume(context, bdm, instance, 5471 bdm = objects.BlockDeviceMapping.get_by_volume_and_instance(
5472 attachment_id=attachment_id) 5472 context, volume_id, instance.uuid)
5473 self._detach_volume(context, bdm, instance,
5474 attachment_id=attachment_id)
5475
5476 do_detach_volume(context, volume_id, instance, attachment_id)
5473 5477
5474 def _init_volume_connection(self, context, new_volume, 5478 def _init_volume_connection(self, context, new_volume,
5475 old_volume_id, connector, bdm, 5479 old_volume_id, connector, bdm,