mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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:
parent
42f6e21d77
commit
b226005982
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user