Skip to content

Commit

Permalink
Fixes ceph-backup failure if original volume deleted
Browse files Browse the repository at this point in the history
Fixes: bug #1199661

Change-Id: I21f979bf2c0ca6910a6437cb6277193f71fed664
  • Loading branch information
dosaboy committed Jul 12, 2013
1 parent 76d8d6c commit f6a8b28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
19 changes: 9 additions & 10 deletions cinder/backup/drivers/ceph.py
Expand Up @@ -122,10 +122,10 @@ def _disconnect_from_rados(self, client, ioctx):
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):
"""
Expand Down Expand Up @@ -198,7 +198,7 @@ def backup(self, backup, volume_file):
"""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))
Expand All @@ -223,9 +223,9 @@ def backup(self, backup, volume_file):

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']))
Expand Down Expand Up @@ -257,9 +257,8 @@ def restore(self, backup, volume_id, volume_file):
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'])

Expand Down
1 change: 0 additions & 1 deletion cinder/volume/drivers/rbd.py
Expand Up @@ -544,7 +544,6 @@ def backup_volume(self, context, backup, backup_service):

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:
Expand Down

0 comments on commit f6a8b28

Please sign in to comment.