Check for migrated UUID in SolidFire delete
Migration of volumes kinda screws up the use of ID as the reference to use for deleting volumes. If a volume is migrated, the UUID (ID) gets swapped and no longer matches the UUID the volume had when it was initially created on the back end device. The result is that deletion of that volume fails on the back end because the handle to the new UUID doesn't exist. On the other hand, you also have to be careful in dealing with and cleaning up volumes migrated off of your back end device for the same types of reasons. This change just adds an additional check in the SF driver so that we are querying the back end device for the ID and the name_id. This way we make sure if the volume is on our device we clean it up. Change-Id: I60f8e8864f236fb92dd03560576377f1a0bdd82b Closes-Bug: #1733967
This commit is contained in:
parent
478acdc260
commit
0e6ee1b1df
|
@ -27,6 +27,7 @@ from cinder import exception
|
|||
from cinder.objects import fields
|
||||
from cinder import test
|
||||
from cinder.tests.unit.image import fake as fake_image
|
||||
from cinder.tests.unit import utils as test_utils
|
||||
from cinder.volume import configuration as conf
|
||||
from cinder.volume.drivers import solidfire
|
||||
from cinder.volume import qos_specs
|
||||
|
@ -517,15 +518,13 @@ class SolidFireVolumeTestCase(test.TestCase):
|
|||
|
||||
def test_delete_volume(self):
|
||||
vol_id = 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'
|
||||
testvol = {'project_id': 'testprjid',
|
||||
'name': 'test_volume',
|
||||
'size': 1,
|
||||
'id': vol_id,
|
||||
'name_id': vol_id,
|
||||
'created_at': timeutils.utcnow(),
|
||||
'provider_id': '1 5 None',
|
||||
'multiattach': True
|
||||
}
|
||||
testvol = test_utils.create_volume(
|
||||
self.ctxt,
|
||||
id=vol_id,
|
||||
display_name='test_volume',
|
||||
provider_id='1 5 None',
|
||||
multiattach=True)
|
||||
|
||||
fake_sfaccounts = [{'accountID': 5,
|
||||
'name': 'testprjid',
|
||||
'targetSecret': 'shhhh',
|
||||
|
@ -566,13 +565,7 @@ class SolidFireVolumeTestCase(test.TestCase):
|
|||
'targetSecret': 'shhhh',
|
||||
'username': 'john-wayne'}]
|
||||
fake_no_volumes = []
|
||||
vol_id = 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'
|
||||
testvol = {'project_id': 'testprjid',
|
||||
'name': 'no-name',
|
||||
'size': 1,
|
||||
'id': vol_id,
|
||||
'name_id': vol_id,
|
||||
'created_at': timeutils.utcnow()}
|
||||
testvol = test_utils.create_volume(self.ctxt)
|
||||
|
||||
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
|
||||
with mock.patch.object(sfv,
|
||||
|
@ -589,14 +582,12 @@ class SolidFireVolumeTestCase(test.TestCase):
|
|||
'targetSecret': 'shhhh',
|
||||
'username': 'john-wayne'}]
|
||||
fake_no_volumes = []
|
||||
snap_id = 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'
|
||||
testsnap = {'project_id': 'testprjid',
|
||||
'name': 'no-name',
|
||||
'size': 1,
|
||||
'id': snap_id,
|
||||
'name_id': snap_id,
|
||||
'volume_id': 'b831c4d1-d1f0-11e1-9b23-0800200c9a66',
|
||||
'created_at': timeutils.utcnow()}
|
||||
testvol = test_utils.create_volume(
|
||||
self.ctxt,
|
||||
volume_id='b831c4d1-d1f0-11e1-9b23-0800200c9a66')
|
||||
testsnap = test_utils.create_snapshot(
|
||||
self.ctxt,
|
||||
volume_id=testvol.id)
|
||||
|
||||
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
|
||||
with mock.patch.object(sfv,
|
||||
|
|
|
@ -1437,7 +1437,12 @@ class SolidFireDriver(san.SanISCSIDriver):
|
|||
|
||||
for acc in accounts:
|
||||
vols = self._get_volumes_for_account(acc['accountID'],
|
||||
volume['name_id'])
|
||||
volume.name_id)
|
||||
# Check for migration magic here
|
||||
if (not vols and (volume.name_id != volume.id)):
|
||||
vols = self._get_volumes_for_account(acc['accountID'],
|
||||
volume.id)
|
||||
|
||||
if vols:
|
||||
sf_vol = vols[0]
|
||||
break
|
||||
|
@ -1488,9 +1493,9 @@ class SolidFireDriver(san.SanISCSIDriver):
|
|||
params,
|
||||
version='6.0')
|
||||
return
|
||||
# Make sure it's not "old style" using clones as snaps
|
||||
LOG.debug("Snapshot not found, checking old style clones.")
|
||||
self.delete_volume(snapshot)
|
||||
LOG.warning(
|
||||
"Snapshot %s not found, old style clones may not be deleted.",
|
||||
snapshot.id)
|
||||
|
||||
def create_snapshot(self, snapshot):
|
||||
sfaccount = self._get_sfaccount(snapshot['project_id'])
|
||||
|
|
Loading…
Reference in New Issue