mirror of https://github.com/apache/cloudstack.git
storage: publish delete usage event for snapshot deletion (#3212)
Problem: Users are billed for destroyed VMs with VM snapshots because usage records don't get that the VM and VM snapshots are removed. Root Cause: The destroyVirtualMachine and expungeVirtualMachine APIs were removing VM snapshots but not generating VMSNAPSHOT.DELETE usage event due to which the VM snapshots were not marked as removed in the usage_vmsnapshot table. Solution: The issue was fixed by emitting the proper usage event for all the VM snapshots of a VM that is destroyed.
This commit is contained in:
parent
1af5dedfb1
commit
491a10be0c
|
|
@ -423,6 +423,12 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot
|
|||
s_logger.debug("Failed to change vm snapshot state with event ExpungeRequested");
|
||||
throw new CloudRuntimeException("Failed to change vm snapshot state with event ExpungeRequested: " + e.getMessage());
|
||||
}
|
||||
UserVm userVm = userVmDao.findById(vmSnapshot.getVmId());
|
||||
List<VolumeObjectTO> volumeTOs = vmSnapshotHelper.getVolumeTOList(userVm.getId());
|
||||
for (VolumeObjectTO volumeTo: volumeTOs) {
|
||||
volumeTo.setSize(0);
|
||||
publishUsageEvent(EventTypes.EVENT_VM_SNAPSHOT_DELETE, vmSnapshot, userVm, volumeTo);
|
||||
}
|
||||
return vmSnapshotDao.remove(vmSnapshot.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue