summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Correa <thiagoc@netapp.com>2020-02-20 18:07:23 +0000
committerFernando Ferraz <sfernand@netapp.com>2020-10-15 17:39:12 +0000
commit3563e75687b4d581a37e168817727fb37e7d3e4c (patch)
tree9889d02ab7c0a073d8750e5e8be72da82ce1bc90
parent73ba22632b9edbb0fd65907adc0893614e300569 (diff)
downloadcinder-3563e75687b4d581a37e168817727fb37e7d3e4c.tar.gz
NetApp SolidFire: Fix retype to SolidFire
Cinder can successfully retype an attached volume from SolidFire to different backends, but the other way around was failing. This patch fixes this issue, allowing retype operation for attached volumes from other backends to SolidFire. Change-Id: I75b828198a2af707d59120f29704a81ba9f2b553 Closes-bug: #1859652 (cherry picked from commit ca475a3dad993624920d2bcbe65bf98162f32e2f) (cherry picked from commit 0a223ff59cab6cca7491d2e774957f5b9f06a550)
-rw-r--r--cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py30
-rw-r--r--cinder/volume/drivers/solidfire.py9
-rw-r--r--releasenotes/notes/bug-1859652-netapp-fix-retype-attached-volume-to-solidfire-1933f03673ff078d.yaml5
3 files changed, 43 insertions, 1 deletions
diff --git a/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py b/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py
index 0e0ebc79e..305bf87a8 100644
--- a/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py
+++ b/cinder/tests/unit/volume/drivers/solidfire/test_solidfire.py
@@ -1323,6 +1323,36 @@ class SolidFireVolumeTestCase(test.TestCase):
self.assertTrue(migrated)
self.assertEqual({}, updates)
+ @data(None, 'Success', 'Error', 'target:{}'.format(f_uuid[0]))
+ @mock.patch.object(solidfire.SolidFireDriver, '_get_sf_volume')
+ @mock.patch.object(solidfire.SolidFireDriver, '_get_sfaccount')
+ def test_attach_volume(self, mig_status, mock_get_sfaccount,
+ mock_get_sf_volume):
+
+ mock_get_sfaccount.return_value = self.fake_sfaccount
+ i_uuid = 'fake_instance_uuid'
+ ctx = context.get_admin_context()
+ type_fields = {}
+ vol_type = fake_volume.fake_volume_type_obj(ctx, **type_fields)
+ utc_now = timeutils.utcnow().isoformat()
+ vol_fields = {
+ 'id': f_uuid[0],
+ 'created_at': utc_now,
+ 'volume_type': vol_type,
+ 'volume_type_id': vol_type.id,
+ 'migration_status': mig_status,
+ }
+ vol = fake_volume.fake_volume_obj(ctx, **vol_fields)
+ sf_vol = self.fake_sfvol
+ mock_get_sf_volume.return_value = sf_vol
+
+ sfv = solidfire.SolidFireDriver(configuration=self.configuration)
+ sfv.attach_volume(ctx, vol, i_uuid, 'fake_host', '/dev/sdf')
+ self.assertEqual(sf_vol['attributes']['attached_to'],
+ i_uuid)
+ mock_get_sfaccount.assert_called()
+ mock_get_sf_volume.assert_called()
+
def test_retype_with_qos_spec(self):
test_type = {'name': 'sf-1',
'qos_specs_id': 'fb0576d7-b4b5-4cad-85dc-ca92e6a497d1',
diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py
index 40c26fbb8..d1977ee18 100644
--- a/cinder/volume/drivers/solidfire.py
+++ b/cinder/volume/drivers/solidfire.py
@@ -2076,7 +2076,14 @@ class SolidFireDriver(san.SanISCSIDriver):
sfaccount = self._get_sfaccount(volume['project_id'])
params = {'accountID': sfaccount['accountID']}
- sf_vol = self._get_sf_volume(volume['id'], params)
+ # In a retype of an attached volume scenario, the volume id will be
+ # as a target on 'migration_status', otherwise it'd be None.
+ migration_status = volume.get('migration_status')
+ if migration_status and 'target' in migration_status:
+ __, vol_id = migration_status.split(':')
+ else:
+ vol_id = volume['id']
+ sf_vol = self._get_sf_volume(vol_id, params)
if sf_vol is None:
LOG.error("Volume ID %s was not found on "
"the SolidFire Cluster while attempting "
diff --git a/releasenotes/notes/bug-1859652-netapp-fix-retype-attached-volume-to-solidfire-1933f03673ff078d.yaml b/releasenotes/notes/bug-1859652-netapp-fix-retype-attached-volume-to-solidfire-1933f03673ff078d.yaml
new file mode 100644
index 000000000..629215760
--- /dev/null
+++ b/releasenotes/notes/bug-1859652-netapp-fix-retype-attached-volume-to-solidfire-1933f03673ff078d.yaml
@@ -0,0 +1,5 @@
+---
+fixes:
+ - |
+ Fixed `bug #1859652 <https://bugs.launchpad.net/cinder/+bug/1859652>`_
+ to allow retyping an attached volume to SolidFire.