]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixes ceph-backup failure if original volume deleted
authorEdward Hope-Morley <edward.hope-morley@canonical.com>
Thu, 11 Jul 2013 18:38:15 +0000 (19:38 +0100)
committerEdward Hope-Morley <edward.hope-morley@canonical.com>
Fri, 12 Jul 2013 08:56:06 +0000 (09:56 +0100)
Fixes: bug #1199661
Change-Id: I21f979bf2c0ca6910a6437cb6277193f71fed664

cinder/backup/drivers/ceph.py
cinder/volume/drivers/rbd.py

index 3ab8822894a6f07908e580ca86409b933b66bb11..ee9575f5caaed51a32d728e035954d2d90b6a3a9 100644 (file)
@@ -122,10 +122,10 @@ class CephBackupDriver(BackupDriver):
         ioctx.close()
         client.shutdown()
 
-    def _get_backup_rbd_name(self, vol_name, backup_id):
-        """Make sure we use a consistent format for backup names"""
-        # ensure no unicode
-        return str("%s.backup.%s" % (vol_name, backup_id))
+    def _get_backup_base_name(self, volume_id, backup_id):
+        """Return name of base image used for backup."""
+        # Ensure no unicode
+        return str("volume-%s.backup.%s" % (volume_id, backup_id))
 
     def _transfer_data(self, src, dest, dest_name, length, dest_is_rbd=False):
         """
@@ -198,7 +198,7 @@ class CephBackupDriver(BackupDriver):
         """Backup the given volume to Ceph object store"""
         backup_id = backup['id']
         volume = self.db.volume_get(self.context, backup['volume_id'])
-        backup_name = self._get_backup_rbd_name(volume['name'], backup_id)
+        backup_name = self._get_backup_base_name(volume['id'], backup_id)
 
         LOG.debug("Starting backup of volume='%s' to rbd='%s'" %
                   (volume['name'], backup_name))
@@ -223,9 +223,9 @@ class CephBackupDriver(BackupDriver):
 
     def restore(self, backup, volume_id, volume_file):
         """Restore the given volume backup from Ceph object store"""
-        volume_id = backup['volume_id']
         volume = self.db.volume_get(self.context, volume_id)
-        backup_name = self._get_backup_rbd_name(volume['name'], backup['id'])
+        backup_name = self._get_backup_base_name(backup['volume_id'],
+                                                 backup['id'])
 
         LOG.debug('starting backup restore from Ceph backup=%s '
                   'to volume=%s' % (backup['id'], volume['name']))
@@ -257,9 +257,8 @@ class CephBackupDriver(BackupDriver):
     def delete(self, backup):
         """Delete the given backup from Ceph object store"""
         backup_id = backup['id']
-        volume_id = backup['volume_id']
-        volume = self.db.volume_get(self.context, volume_id)
-        backup_name = self._get_backup_rbd_name(volume['name'], backup_id)
+        backup_name = self._get_backup_base_name(backup['volume_id'],
+                                                 backup_id)
 
         LOG.debug('delete started for backup=%s', backup['id'])
 
index 288742b089343085fe5f70c5dce85b48a5bda9fc..b59de7ce6b776db5bc49142b57b6911e1e376900 100644 (file)
@@ -544,7 +544,6 @@ class RBDDriver(driver.VolumeDriver):
 
     def restore_backup(self, context, backup, volume, backup_service):
         """Restore an existing backup to a new or existing volume."""
-        volume = self.db.volume_get(context, backup['volume_id'])
         pool = self.configuration.rbd_pool
 
         with RBDVolumeProxy(self, volume['name'], pool) as rbd_image: