From: Avishay Traeger Date: Mon, 2 Sep 2013 17:23:45 +0000 (+0300) Subject: Soft delete tmp migration volume X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=d2479f1e88e1eff777afbc922ae1da63afcc7716;p=openstack-build%2Fcinder-build.git Soft delete tmp migration volume 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 --- diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index 8de30757c..79aa0b4b7 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -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 diff --git a/cinder/tests/db/test_finish_migration.py b/cinder/tests/db/test_finish_migration.py index 459dfea62..4fba2a91f 100644 --- a/cinder/tests/db/test_finish_migration.py +++ b/cinder/tests/db/test_finish_migration.py @@ -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']) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 54ac3825b..46aac1fdc 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -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']