]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix volume_glance_metadata deletion
authorAdalberto Medeiros <adalbas@linux.vnet.ibm.com>
Tue, 13 Aug 2013 18:50:24 +0000 (14:50 -0400)
committerAdalberto Medeiros <adalbas@linux.vnet.ibm.com>
Tue, 20 Aug 2013 20:36:00 +0000 (16:36 -0400)
If volume_glance_metadata does not exist for a certain volume,
it returns an exception and does not delete volume from db.
Avoid deleting it if it does not exist.

Bug: 1209367
Change-Id: Ia607ec5ecfc115c1a593f14236ee93158938a8da

cinder/volume/manager.py

index 1784837cf85978203c3816fc7d54685ffa4bd195..3dfe561ca41610d2180b83470a5c62a8280c9473 100644 (file)
@@ -258,7 +258,15 @@ class VolumeManager(manager.SchedulerDependentManager):
             reservations = None
             LOG.exception(_("Failed to update usages deleting volume"))
 
-        self.db.volume_glance_metadata_delete_by_volume(context, volume_id)
+        # Delete glance metadata if it exists
+        try:
+            self.db.volume_glance_metadata_delete_by_volume(context, volume_id)
+            LOG.debug(_("volume %s: glance metadata deleted"),
+                      volume_ref['id'])
+        except exception.GlanceMetadataNotFound:
+            LOG.debug(_("no glance metadata found for volume %s"),
+                      volume_ref['id'])
+
         self.db.volume_destroy(context, volume_id)
         LOG.info(_("volume %s: deleted successfully"), volume_ref['id'])
         self._notify_about_volume_usage(context, volume_ref, "delete.end")