Skip to content

Conversation

@hsato03
Copy link
Collaborator

@hsato03 hsato03 commented Nov 28, 2025

Description

When migrating a volume snapshot from one secondary storage to another using the migrateSecondaryStorageData and migrateResourceToAnotherSecondaryStorage APIs, its physical size is set to 0.

This behavior was changed to preserve the physical size of the snapshot after migration.

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?

I migrated a volume snapshot using the migrateSecondaryStorageData and migrateResourceToAnotherSecondaryStorage APIs and verified that its physical size had not changed.

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

@hsato03
Copy link
Collaborator Author

hsato03 commented Nov 28, 2025

@blueorangutan package

@blueorangutan
Copy link

@hsato03 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 Nov 28, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 17.56%. Comparing base (db61470) to head (e81766a).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...ack/storage/image/SecondaryStorageServiceImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #12166      +/-   ##
============================================
- Coverage     17.56%   17.56%   -0.01%     
+ Complexity    15548    15547       -1     
============================================
  Files          5913     5913              
  Lines        529440   529440              
  Branches      64670    64670              
============================================
- Hits          93019    93018       -1     
- Misses       425963   425964       +1     
  Partials      10458    10458              
Flag Coverage Δ
uitests 3.58% <ø> (ø)
unittests 18.63% <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 fixes a bug where volume snapshot physical size was incorrectly set to 0 after migration between secondary storages using the migrateSecondaryStorageData and migrateResourceToAnotherSecondaryStorage APIs.

  • Corrected the lookup of the destination snapshot store to use destination data store ID and snapshot ID instead of source parameters
  • Aligned the snapshot handling pattern with the existing VolumeInfo and TemplateInfo handling in the same method
Comments suppressed due to low confidence (1)

engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/SecondaryStorageServiceImpl.java:291

  • The fixed bug in the updateDataObject method lacks test coverage. Consider adding a test case to verify that after migrating a snapshot between secondary storages, the physical size is correctly preserved. This would prevent similar regressions in the future.
    private void updateDataObject(DataObject srcData, DataObject destData) {
        if (destData instanceof SnapshotInfo) {
            SnapshotDataStoreVO snapshotStore = snapshotStoreDao.findBySourceSnapshot(srcData.getId(), DataStoreRole.Image);
            SnapshotDataStoreVO destSnapshotStore = snapshotStoreDao.findByStoreSnapshot(DataStoreRole.Image, destData.getDataStore().getId(), destData.getId());
            if (snapshotStore != null && destSnapshotStore != null) {
                destSnapshotStore.setPhysicalSize(snapshotStore.getPhysicalSize());
                destSnapshotStore.setCreated(snapshotStore.getCreated());
                if (snapshotStore.getParentSnapshotId() != destSnapshotStore.getParentSnapshotId()) {
                    destSnapshotStore.setParentSnapshotId(snapshotStore.getParentSnapshotId());
                }
                snapshotStoreDao.update(destSnapshotStore.getId(), destSnapshotStore);
            }

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

@blueorangutan
Copy link

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

Copy link
Member

@bernardodemarco bernardodemarco left a comment

Choose a reason for hiding this comment

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

code lgtm

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.

3 participants