Skip to content

Conversation

@sureshanaparti
Copy link
Contributor

@sureshanaparti sureshanaparti commented Jan 28, 2026

Description

This PR updates storage usage / size in backup usage response.

Fixes #12536

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)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

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?

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti 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.

@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.26%. Comparing base (35e6d7c) to head (6d7808a).
⚠️ Report is 4 commits behind head on 4.20.

Files with missing lines Patch % Lines
...src/main/java/com/cloud/api/ApiResponseHelper.java 0.00% 2 Missing ⚠️
...java/com/cloud/usage/parser/BackupUsageParser.java 0.00% 1 Missing ⚠️
.../cloud/usage/parser/VMSnapshotOnPrimaryParser.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #12539   +/-   ##
=========================================
  Coverage     16.26%   16.26%           
  Complexity    13418    13418           
=========================================
  Files          5658     5658           
  Lines        499494   499496    +2     
  Branches      60625    60625           
=========================================
+ Hits          81232    81234    +2     
  Misses       409214   409214           
  Partials       9048     9048           
Flag Coverage Δ
uitests 4.02% <ø> (ø)
unittests 17.12% <0.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the backup usage response to include storage size information that was previously stored but not exposed through the API.

Changes:

  • Removed unused rawUsage variable from BackupUsageParser
  • Modernized Double instantiation to use primitive casting in BackupUsageParser and VMSnapshotOnPrimaryParser
  • Added size and virtualSize fields to backup usage API response

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
usage/src/main/java/com/cloud/usage/parser/BackupUsageParser.java Removed unused variable and modernized Double casting for better code quality
usage/src/main/java/com/cloud/usage/parser/VMSnapshotOnPrimaryParser.java Modernized Double casting from new Double(usage) to (double) usage
server/src/main/java/com/cloud/api/ApiResponseHelper.java Added setSize() and setVirtualSize() calls to populate backup storage metrics in usage response

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RosiKyu RosiKyu self-assigned this Jan 28, 2026
@blueorangutan
Copy link

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

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm

Copy link
Collaborator

@abh1sar abh1sar left a comment

Choose a reason for hiding this comment

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

Need to fix the print statement in createUsageResponse

        } else if (usageRecord.getUsageType() == UsageTypes.BACKUP) {
            resourceType = ResourceObjectType.Backup;
            final StringBuilder builder = new StringBuilder();
            builder.append("Backup usage of size ").append(usageRecord.getUsageDisplay());
            if (vmInstance != null) {
                resourceId = vmInstance.getId();
                usageRecResponse.setResourceName(vmInstance.getInstanceName());
                usageRecResponse.setUsageId(vmInstance.getUuid());
                builder.append(" for VM ").append(vmInstance.getHostName())
                        .append(" (").append(vmInstance.getUuid()).append(")");
                final BackupOffering backupOffering = backupOfferingDao.findByIdIncludingRemoved(usageRecord.getOfferingId());
                if (backupOffering != null) {
                    builder.append(" and backup offering ").append(backupOffering.getName())
                            .append(" (").append(backupOffering.getUuid()).append(", user ad-hoc/scheduled backup allowed: ")
                            .append(backupOffering.isUserDrivenBackupAllowed()).append(")");
                }

            }

Is should say something like

Backup usage for VM .. and backup offering ... with size (usageRecord.getSize()

Currently it shows

Image

Snapshot usage for reference

Image

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.

listUsageRecords for backup usage (type 28) isn't returning the backup storage usage

5 participants