Skip to content

Fixes VM snapshot usage records that are attributed to the old snapshot - #14308

Draft
harikrishna-patnala wants to merge 2 commits into
apache:4.22from
shapeblue:vm-snapshot-usage-fix
Draft

harikrishna-patnala wants to merge 2 commits into
apache:4.22from
shapeblue:vm-snapshot-usage-fix

Conversation

@harikrishna-patnala

@harikrishna-patnala harikrishna-patnala commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Description

This PR fixes #13921

Here we used the right usage record to get the actual snapshot details.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@codecov

codecov Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.52632% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.34%. Comparing base (b56bbc2) to head (e7fe6f9).

Files with missing lines Patch % Lines
...rc/main/java/com/cloud/usage/UsageManagerImpl.java 45.83% 12 Missing and 1 partial ⚠️
...va/com/cloud/usage/dao/UsageVMSnapshotDaoImpl.java 0.00% 1 Missing ⚠️
.../com/cloud/usage/parser/VMSnapshotUsageParser.java 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #14308      +/-   ##
============================================
+ Coverage     18.32%   18.34%   +0.01%     
- Complexity    16644    16658      +14     
============================================
  Files          5939     5939              
  Lines        537787   537785       -2     
  Branches      65932    65931       -1     
============================================
+ Hits          98544    98630      +86     
+ Misses       428033   427942      -91     
- Partials      11210    11213       +3     
Flag Coverage Δ
uitests 4.08% <ø> (ø)
unittests 19.43% <60.52%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@weizhouapache weizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code makes sense

@harikrishna-patnala
harikrishna-patnala marked this pull request as draft October 5, 2026 09:21
@nvazquez nvazquez modified the milestones: 4.22.2, 4.22.3 Nov 9, 2026
The parser chained usage_vmsnapshot rows of the same VM/volume as if a newer
VM snapshot replaced the older one: the older snapshot was billed only up to
the creation of the newer one and then marked processed, so it stopped
accruing usage. Keying the map by snapshot id alone also made the older
snapshot be billed twice for the overlap within the same period.

- Bill every row from max(created, startDate) to min(deleted, endDate),
  like VMSnapshotOnPrimaryUsageParser does; the parser no longer writes the
  processed column, which is now only set by the delete event.
- Include rows deleted during the period in getUsageRecords, so the last
  partial period before deletion is billed.
- On VM snapshot delete, only close the rows of the deleted snapshot/volume
  instead of all snapshot rows of the VM (falls back to the old behaviour
  for legacy events without a vmSnapshotId detail).
@harikrishna-patnala

Copy link
Copy Markdown
Member Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@harikrishna-patnala a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20011

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VM snapshot usage records are attributed to the wrong snapshot; older snapshots stop accruing usage entirely

4 participants