bug 8130: destroying all vols associated with a vm in error state, during the vm creation flow

status 8130: resolved fixed
This commit is contained in:
abhishek 2011-01-26 15:11:30 -08:00
parent 42f6e21d77
commit b226005982
2 changed files with 10 additions and 1 deletions

View File

@ -365,7 +365,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
UserVmVO userVm = _vmDao.findById(v.getInstanceId());
if(userVm != null) {
if(userVm.getState().equals(State.Destroyed) || userVm.getState().equals(State.Expunging)) {
throw new CloudRuntimeException("Creating snapshot failed due to volume:" + volumeId + " is associated with vm:"+userVm.getInstanceName()+" which is in "+userVm.getState().toString()+" state");
throw new CloudRuntimeException("Creating snapshot failed due to volume:" + volumeId + " is associated with vm:"+userVm.getInstanceName()+" is in "+userVm.getState().toString()+" state");
}
}
}

View File

@ -1488,6 +1488,15 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
if(vm != null){
if(vm.getState().equals(State.Stopped)){
_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationFailed, null);
//destroy associated volumes for vm in error state
List<VolumeVO> volumesForThisVm = _volsDao.findByInstance(vm.getId());
for(VolumeVO volume : volumesForThisVm) {
try {
_storageMgr.destroyVolume(volume);
} catch (ConcurrentOperationException e) {
s_logger.warn("Unable to delete volume:"+volume.getId()+" for vm:"+vmId+" whilsts transitioning to error state");
}
}
}
}
}