This is an automated email from the ASF dual-hosted git repository.

harikrishna-patnala pushed a commit to branch vm-snapshot-usage-fix
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit f93b45066a328b9a4eb87a8031b1bc90aea81c5a
Author: Harikrishna Patnala <[email protected]>
AuthorDate: Mon Oct 5 12:28:19 2026 +0530

    Fixes VM snapshot usage records that are attributed to the old snapshot
---
 usage/src/main/java/com/cloud/usage/parser/VMSnapshotUsageParser.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/usage/src/main/java/com/cloud/usage/parser/VMSnapshotUsageParser.java 
b/usage/src/main/java/com/cloud/usage/parser/VMSnapshotUsageParser.java
index 3ea5ee10166..9127df8be98 100644
--- a/usage/src/main/java/com/cloud/usage/parser/VMSnapshotUsageParser.java
+++ b/usage/src/main/java/com/cloud/usage/parser/VMSnapshotUsageParser.java
@@ -65,7 +65,7 @@ public class VMSnapshotUsageParser extends UsageParser {
             long zoneId = usageRec.getZoneId();
             Long volId = usageRec.getVolumeId();
             long vmId = usageRec.getVmId();
-            String key = vmId + ":" + volId;
+            String key = vmId + ":" + volId + ":" + usageRec.getVmSnapshotId();
             if (usageRec.getCreated().before(startDate)) {
                 unprocessedUsage.put(key, usageRec);
                 continue;
@@ -85,7 +85,7 @@ public class VMSnapshotUsageParser extends UsageParser {
             long duration = (createDate.getTime() - previousCreated.getTime()) 
+ 1;
 
             createUsageRecord(UsageTypes.VM_SNAPSHOT, duration, 
previousCreated, createDate, account, volId, zoneId, 
previousEvent.getDiskOfferingId(), vmId,
-                previousEvent.getSize(), usageRec.getVmSnapshotId());
+                previousEvent.getSize(), previousEvent.getVmSnapshotId());
             previousEvent.setProcessed(new Date());
             usageVMSnapshotDao.update(previousEvent);
 

Reply via email to