]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Allow to delete a volume in error_extending status
authorKen'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Tue, 20 Aug 2013 03:26:36 +0000 (12:26 +0900)
committerKen'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
Wed, 21 Aug 2013 07:03:58 +0000 (16:03 +0900)
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

cinder/tests/test_volume.py
cinder/volume/api.py

index aa91f3d9e0cf98c870d9cc25b10a223fe205ec24..e90ce08f62fdce486f37b1bbfd762132a24ac52f 100644 (file)
@@ -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()
index 16a81457741de7c4c318b884ed9afd0ebf8e9760..1a98c61eff66120a383ab9506106166399329fc8 100644 (file)
@@ -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)