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.
This commit is contained in:
Marcus Sorensen 2013-04-19 14:20:57 +01:00 committed by Chip Childers
parent 3d37f2a6e8
commit ccc49875dd
1 changed files with 5 additions and 0 deletions

View File

@ -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());