From 3610f4696f0f5e821e05ddc1a41fd5038d14eb93 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Thu, 21 Dec 2017 15:44:38 -0500 Subject: [PATCH] Use volume shared_targets to lock during attach/detach The Cinder 3.48 API provides a shared_targets and service_uuid field in the volume resource which tells the caller whether or not it should lock operations on that volume. This change adds that logic to the DriverVolumeBlockDevice attach and detach flows by first trying to get the volume at the 3.48 microversion and if that's not available, it simply falls back to get the volume the same as before. If 3.48 is available and the volume storage backend uses shared targets, we synchronize the attach/detach operations using the volume service_uuid, which is based on the storage backend and is also configurable by the deployer on the Cinder side. This is a nice to have protection for "normal" volumes but is really needed for multiattach volumes to be detached safely. See Cinder blueprint add-shared-targets-flag-to-volume for details. Part of blueprint multi-attach-volume Depends-On: I3c07cd8458d55535a71626ffaa8ca50deb3ca3dd Change-Id: I5e96602184242fb9017c0434b445a3875f3b149a --- nova/tests/fixtures.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index 204a8894e..380704a6c 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -1325,7 +1325,7 @@ class CinderFixture(fixtures.Fixture): def setUp(self): super(CinderFixture, self).setUp() - def fake_get(self_api, context, volume_id): + def fake_get(self_api, context, volume_id, microversion=None): # Check for the special swap volumes. if volume_id in (CinderFixture.SWAP_OLD_VOL, CinderFixture.SWAP_ERR_OLD_VOL): @@ -1499,7 +1499,7 @@ class CinderFixtureNewAttachFlow(fixtures.Fixture): def setUp(self): super(CinderFixtureNewAttachFlow, self).setUp() - def fake_get(self_api, context, volume_id): + def fake_get(self_api, context, volume_id, microversion=None): # Check for the special swap volumes. if volume_id in (CinderFixture.SWAP_OLD_VOL, CinderFixture.SWAP_ERR_OLD_VOL):