Updated Branches: refs/heads/4.1 3d37f2a6e -> ccc49875d
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. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ccc49875 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ccc49875 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ccc49875 Branch: refs/heads/4.1 Commit: ccc49875dd4c604a2c7303e1e7afd05df72c4a6e Parents: 3d37f2a Author: Marcus Sorensen <[email protected]> Authored: Fri Apr 19 14:20:57 2013 +0100 Committer: Chip Childers <[email protected]> Committed: Fri Apr 19 14:20:57 2013 +0100 ---------------------------------------------------------------------- .../src/com/cloud/storage/StorageManagerImpl.java | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ccc49875/server/src/com/cloud/storage/StorageManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 624361f..200a886 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());
