From 6338b76a2de7d50d4fc47d8d88f2ba60cf15d939 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Thu, 23 Oct 2014 16:37:11 +0000 Subject: [PATCH] Fix SolidFire inaccurate model on migrated vols The general migration impl in Cinder works by creating a new volume, transfering the data from the original volume to the new volume, and then deleting the original and flipping the ID of the new volume. Turns out we missed the fact that this creates a mismatch between the volume Cinder will later ask for and what the volumes identity is on the backend device. This change adds a check on create_volume at the drivers level to see if it's part of a migration and is infact going to get renamed. If so, just use the new name and avoid all the headaches that come later with updating provider auth and location. The model info won't change in this case and is accessible independent of the ID field in the Cinder base and the crazy change that's going to take place on that value in the Cinder DB. Change-Id: If916df5fd986352ffb20f2dd74552e4d7dad4f60 Closes-Bug: #1381943 --- cinder/tests/test_solidfire.py | 26 ++++++++++++++++++++++++++ cinder/volume/drivers/solidfire.py | 9 +++++++++ cinder/volume/manager.py | 5 +++++ 3 files changed, 40 insertions(+) diff --git a/cinder/tests/test_solidfire.py b/cinder/tests/test_solidfire.py index a6ee0a5e1..36d852209 100644 --- a/cinder/tests/test_solidfire.py +++ b/cinder/tests/test_solidfire.py @@ -634,3 +634,29 @@ class SolidFireVolumeTestCase(test.TestCase): model_update = sfv.manage_existing(testvol, external_ref) self.assertIsNotNone(model_update) self.assertIsNone(model_update.get('provider_geometry', None)) + + def test_create_volume_for_migration(self): + def _fake_do_v_create(self, project_id, params): + return project_id, params + + self.stubs.Set(SolidFireDriver, '_issue_api_request', + self.fake_issue_api_request) + self.stubs.Set(SolidFireDriver, '_do_volume_create', _fake_do_v_create) + + testvol = {'project_id': 'testprjid', + 'name': 'testvol', + 'size': 1, + 'id': 'b830b3c0-d1f0-11e1-9b23-1900200c9a77', + 'volume_type_id': None, + 'created_at': timeutils.utcnow(), + 'migration_status': 'target:' + 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'} + + sfv = SolidFireDriver(configuration=self.configuration) + proj_id, sf_vol_object = sfv.create_volume(testvol) + self.assertEqual('a720b3c0-d1f0-11e1-9b23-0800200c9a66', + sf_vol_object['attributes']['uuid']) + self.assertEqual('b830b3c0-d1f0-11e1-9b23-1900200c9a77', + sf_vol_object['attributes']['migration_uuid']) + self.assertEqual('UUID-a720b3c0-d1f0-11e1-9b23-0800200c9a66', + sf_vol_object['name']) diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index 8d3b15303..be56afb7c 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -519,6 +519,15 @@ class SolidFireDriver(SanISCSIDriver): 'attributes': attributes, 'qos': qos} + # NOTE(jdg): Check if we're a migration tgt, if so + # use the old volume-id here for the SF Name + migration_status = volume.get('migration_status', None) + if migration_status and 'target' in migration_status: + k, v = migration_status.split(':') + params['name'] = 'UUID-%s' % v + params['attributes']['migration_uuid'] = volume['id'] + params['attributes']['uuid'] = v + return self._do_volume_create(volume['project_id'], params) def create_cloned_volume(self, volume, src_vref): diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 8859807bd..30d618b2d 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -1001,6 +1001,11 @@ class VolumeManager(manager.SchedulerDependentManager): new_vol_values['volume_type_id'] = new_type_id new_vol_values['host'] = host['host'] new_vol_values['status'] = 'creating' + + # FIXME(jdg): using a : delimeter is confusing to + # me below here. We're adding a string member to a dict + # using a :, which is kind of a poor choice in this case + # I think new_vol_values['migration_status'] = 'target:%s' % volume['id'] new_vol_values['attach_status'] = 'detached' new_volume = self.db.volume_create(ctxt, new_vol_values) -- 2.45.2