From ccc49875dd4c604a2c7303e1e7afd05df72c4a6e Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Fri, 19 Apr 2013 14:20:57 +0100 Subject: [PATCH] CLOUDSTACK-2104: add state change in createVolume back to Allocated if anything fails Changes: createVolume changes the volume state from 'Allocated' to 'Creating', but has no code to change it back to 'Allocated' if anything goes wrong, despite there already being a path from 'Creating' to 'Allocated' for volumes, via the OperationFailed event. Adding this in fixes the issue and avoids leaving disks in an unusable state. Testing: Tested in devcloud-kvm, volume that was larger than primary storage failed to attack, and went back to 'Allocated' from 'Creating' upon the failure. I was then able to retry, and delete the disk. --- server/src/com/cloud/storage/StorageManagerImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 624361fbc90..200a886fde8 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -837,6 +837,11 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C } if (created == null) { + try { + stateTransitTo(volume, Volume.Event.OperationFailed); + } catch (NoTransitionException e) { + s_logger.debug("Unable to update volume state: " + e.toString()); + } return null; } else { volume.setFolder(pool.getPath());