From: Ken'ichi Ohmichi Date: Tue, 20 Aug 2013 03:26:36 +0000 (+0900) Subject: Allow to delete a volume in error_extending status X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=e95a64d17d67ac8e9e5cc01e145deef8b465c5a5;p=openstack-build%2Fcinder-build.git Allow to delete a volume in error_extending status We must be able to remove "error_extending" volume, because we cannot retrieve it without changing database status. If trying to remove the volume, now it fails like the following: $ cinder delete vol-test01 ERROR: Invalid volume: Volume status must be available or error, but current status is: error_extending $ "error_extending" also would be error status, so it is good to remove the volume. Fixes bug #1214228 Change-Id: I861e7af75f2c50d4e03ef3680dccde73078b4888 --- diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index aa91f3d9e..e90ce08f6 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -354,6 +354,19 @@ class VolumeTestCase(test.TestCase): self.mox.UnsetStubs() self.volume.delete_volume(self.context, volume_id) + def test_delete_volume_in_error_extending(self): + """Test volume can be deleted in error_extending stats.""" + # create a volume + volume = self._create_volume() + self.volume.create_volume(self.context, volume['id']) + + # delete 'error_extending' volume + db.volume_update(self.context, volume['id'], + {'status': 'error_extending'}) + self.volume.delete_volume(self.context, volume['id']) + self.assertRaises(exception.NotFound, db.volume_get, + self.context, volume['id']) + def test_create_volume_from_snapshot(self): """Test volume can be created from a snapshot.""" volume_src = self._create_volume() diff --git a/cinder/volume/api.py b/cinder/volume/api.py index 16a814577..1a98c61ef 100644 --- a/cinder/volume/api.py +++ b/cinder/volume/api.py @@ -211,7 +211,8 @@ class API(base.Base): QUOTAS.commit(context, reservations, project_id=project_id) return if not force and volume['status'] not in ["available", "error", - "error_restoring"]: + "error_restoring", + "error_extending"]: msg = _("Volume status must be available or error, " "but current status is: %s") % volume['status'] raise exception.InvalidVolume(reason=msg)