bug 10382: Move volume delete events to destroyVolume method

status 10382: resolved fixed
This commit is contained in:
kishan 2011-07-06 18:08:07 +05:30
parent ddd416a492
commit 6b4c61a348
3 changed files with 6 additions and 15 deletions

View File

@ -1805,6 +1805,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
if (instanceId == null || (vmInstance.getType().equals(VirtualMachine.Type.User))) {
// Decrement the resource count for volumes belonging user VM's only
_accountMgr.decrementResourceCount(volume.getAccountId(), ResourceType.volume);
// Log usage event for volumes belonging user VM's only
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName());
_usageEventDao.persist(usageEvent);
}
txn.commit();
@ -2445,8 +2448,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
// Check that the volume is not already destroyed
if (volume.getState() != Volume.State.Destroy) {
destroyVolume(volume);
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volumeId, volume.getName());
_usageEventDao.persist(usageEvent);
}
try {
@ -2834,11 +2835,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
// This check is for VM in Error state (volume is already destroyed)
if (!vol.getState().equals(Volume.State.Destroy)) {
destroyVolume(vol);
VMInstanceVO vm = _vmInstanceDao.findById(vmId);
if (vm.getType() == VirtualMachine.Type.User) {
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_DELETE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName());
_usageEventDao.persist(usageEvent);
}
}
toBeExpunged.add(vol);
} else {

View File

@ -1083,10 +1083,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
if (!volume.getState().equals(Volume.State.Destroy)) {
try {
_storageMgr.destroyVolume(volume);
if (volume.getPoolId() != null) {
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName());
_usageEventDao.persist(usageEvent);
}
} catch (ConcurrentOperationException ex) {
s_logger.warn("Failed to cleanup volumes as a part of account id=" + accountId + " cleanup due to Exception: ", ex);
accountCleanupNeeded = true;

View File

@ -1646,10 +1646,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
List<VolumeVO> volumesForThisVm = _volsDao.findUsableVolumesForInstance(vm.getId());
for (VolumeVO volume : volumesForThisVm) {
try {
_storageMgr.destroyVolume(volume);
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName());
_usageEventDao.persist(usageEvent);
if (volume.getState() != Volume.State.Destroy) {
_storageMgr.destroyVolume(volume);
}
} catch (ConcurrentOperationException e) {
s_logger.warn("Unable to delete volume:" + volume.getId() + " for vm:" + vmId + " whilst transitioning to error state");
}