]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Soft delete tmp migration volume
authorAvishay Traeger <avishay@il.ibm.com>
Mon, 2 Sep 2013 17:23:45 +0000 (20:23 +0300)
committerAvishay Traeger <avishay@il.ibm.com>
Wed, 18 Sep 2013 04:32:02 +0000 (07:32 +0300)
Previously the row for the temporary migration volume was deleted from
the database, which caused a foreign key violation for its admin
metadata. Regardless, the volume should have been soft deleted from the
database anyway, and this patch takes care of that.

Change-Id: I8e4942b0e21ec79c90aa95b18b5612b5b133fd62
Closes-Bug: #1219097

cinder/db/sqlalchemy/api.py
cinder/tests/db/test_finish_migration.py
cinder/volume/manager.py

index 8de30757c06938636965943aff2ef5a2816aa73b..79aa0b4b710c3e8330576d32937dd0fb3d7d1ea3 100644 (file)
@@ -1119,9 +1119,6 @@ def finish_volume_migration(context, src_vol_id, dest_vol_id):
         session.query(models.Volume).\
             filter_by(id=src_vol_id).\
             update(updates)
-        session.query(models.Volume).\
-            filter_by(id=dest_vol_id).\
-            delete()
 
 
 @require_admin_context
index 459dfea62260620ba4fe6c9f181f89ac989f0755..4fba2a91fe96006cce61b8e5ff086f19ff64baad 100644 (file)
@@ -44,8 +44,6 @@ class FinishVolumeMigrationTestCase(test.TestCase):
         db.finish_volume_migration(ctxt, src_volume['id'],
                                    dest_volume['id'])
 
-        self.assertRaises(exception.VolumeNotFound, db.volume_get, ctxt,
-                          dest_volume['id'])
         src_volume = db.volume_get(ctxt, src_volume['id'])
         expected_name = 'volume-%s' % dest_volume['id']
         self.assertEqual(src_volume['_name_id'], dest_volume['id'])
index 54ac3825b356ac1b94312ea1a2e4d48c5f08da7e..46aac1fdc8ca8be157c45f63b5355ef675bb7453 100644 (file)
@@ -705,6 +705,7 @@ class VolumeManager(manager.SchedulerDependentManager):
             LOG.error(msg % {'vol': volume_id, 'err': ex})
 
         self.db.finish_volume_migration(ctxt, volume_id, new_volume_id)
+        self.db.volume_destroy(ctxt, new_volume_id)
         self.db.volume_update(ctxt, volume_id, {'migration_status': None})
         return volume['id']