Skip to content

Commit

Permalink
Allow snapshots in error state to be deleted.
Browse files Browse the repository at this point in the history
 * Fixes bug 968682

Change-Id: I37fd8e84e50b2f824f978eb7e3181ffb6ddde537
  • Loading branch information
sleepsonthefloor authored and vishvananda committed Mar 31, 2012
1 parent 5800221 commit e691eaf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions nova/tests/test_volume.py
Expand Up @@ -275,7 +275,27 @@ def test_cant_delete_volume_with_snapshots(self):
volume_api.delete,
self.context,
volume)
self.volume.delete_snapshot(self.context, snapshot_id)
self.volume.delete_volume(self.context, volume['id'])

def test_can_delete_errored_snapshot(self):
"""Test snapshot can be created and deleted."""
volume = self._create_volume()
self.volume.create_volume(self.context, volume['id'])
snapshot_id = self._create_snapshot(volume['id'])
self.volume.create_snapshot(self.context, volume['id'], snapshot_id)
snapshot = db.snapshot_get(context.get_admin_context(),
snapshot_id)

volume_api = nova.volume.api.API()

snapshot['status'] = 'badstatus'
self.assertRaises(exception.InvalidVolume,
volume_api.delete_snapshot,
self.context,
snapshot)

snapshot['status'] = 'error'
self.volume.delete_snapshot(self.context, snapshot_id)
self.volume.delete_volume(self.context, volume['id'])

Expand Down
4 changes: 2 additions & 2 deletions nova/volume/api.py
Expand Up @@ -321,8 +321,8 @@ def create_snapshot_force(self, context, volume, name, description):

@wrap_check_policy
def delete_snapshot(self, context, snapshot):
if snapshot['status'] != "available":
msg = _("must be available")
if snapshot['status'] not in ["available", "error"]:
msg = _("Volume Snapshot status must be available or error")
raise exception.InvalidVolume(reason=msg)
self.db.snapshot_update(context, snapshot['id'],
{'status': 'deleting'})
Expand Down

0 comments on commit e691eaf

Please sign in to comment.