cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [cloudstack] branch master updated: storage: publish delete usage event for snapshot deletion (#3212)
Date Wed, 10 Apr 2019 11:43:04 GMT
This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch master
in repository

The following commit(s) were added to refs/heads/master by this push:
     new 491a10b  storage: publish delete usage event for snapshot deletion (#3212)
491a10b is described below

commit 491a10be0c77716ead01961f50328f5d81c6497c
Author: Rohit Yadav <>
AuthorDate: Wed Apr 10 17:12:55 2019 +0530

    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.
 .../cloudstack/storage/vmsnapshot/    | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/
index ebe8b27..19777f0 100644
--- a/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/
+++ b/engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/
@@ -423,6 +423,12 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements
             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());

View raw message