mirror of https://github.com/apache/cloudstack.git
bug 10382: Move volume delete events to destroyVolume method
status 10382: resolved fixed
This commit is contained in:
parent
c62ad3d11a
commit
561f415d5a
|
|
@ -1821,6 +1821,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();
|
||||
|
|
@ -2465,8 +2468,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 {
|
||||
|
|
@ -2854,11 +2855,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 {
|
||||
|
|
|
|||
|
|
@ -1092,10 +1092,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;
|
||||
|
|
|
|||
|
|
@ -1652,10 +1652,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
if (volume.getState() != Volume.State.Destroy) {
|
||||
_storageMgr.destroyVolume(volume);
|
||||
}
|
||||
if (volume.getState() == Volume.State.Ready) {
|
||||
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName());
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.warn("Unable to delete volume:" + volume.getId() + " for vm:" + vmId + " whilst transitioning to error state");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue