Skip to content

Conversation

@slavkap
Copy link
Contributor

@slavkap slavkap commented Jul 30, 2025

Description

This PR fixes the deployment of a VM with a snapshot that is copied to another zone.
Fix for creating StorPool volume from a snapshot if the size in the offering is bigger than the snapshot size

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?

Manually tested

@codecov
Copy link

codecov bot commented Jul 30, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.35%. Comparing base (d7b7bd5) to head (2d2990d).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...rapper/StorPoolDownloadTemplateCommandWrapper.java 0.00% 1 Missing ⚠️
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11351      +/-   ##
============================================
- Coverage     17.35%   17.35%   -0.01%     
+ Complexity    15231    15229       -2     
============================================
  Files          5885     5885              
  Lines        525611   525617       +6     
  Branches      64160    64157       -3     
============================================
- Hits          91224    91214      -10     
- Misses       424090   424107      +17     
+ Partials      10297    10296       -1     
Flag Coverage Δ
uitests 3.63% <ø> (ø)
unittests 18.39% <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.

@DaanHoogland DaanHoogland requested a review from Copilot July 30, 2025 13:08
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 VM deployment issues when using snapshots from different zones, specifically addressing StorPool volume creation from snapshots when the offering size exceeds the snapshot size.

  • Removed complex volume size determination logic in favor of standardized disk size configuration
  • Eliminated override disk offering assignments for both volume and snapshot-based deployments
  • Fixed StorPool template resizing to only apply to template objects, not all storage objects

Reviewed Changes

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

File Description
UserVmManagerImpl.java Simplified volume size calculation and removed disk offering overrides for cross-zone deployments
StorPoolDownloadTemplateCommandWrapper.java Moved StorPool resize operation to only execute for template objects

volumesSize = configureCustomRootDiskSize(customParameters, template, hypervisorType, rootDiskOffering);
}
long volumesSize = configureCustomRootDiskSize(customParameters, template, hypervisorType, rootDiskOffering);

Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

The simplified logic now ignores the actual size of existing volumes and snapshots, which could lead to data loss or corruption when the configured size is smaller than the source volume/snapshot size. Consider adding validation to ensure the configured size is at least as large as the source.

Suggested change
// Validate that the configured size is at least as large as the source volume or snapshot size
if (snapshot != null) {
long sourceSize = snapshot.getSize(); // Assuming snapshot.getSize() returns the size in bytes
if (volumesSize < sourceSize) {
throw new InvalidParameterValueException("The configured root disk size (" + volumesSize +
" bytes) is smaller than the source snapshot size (" + sourceSize + " bytes).");
}
} else if (volume != null) {
long sourceSize = volume.getSize(); // Assuming volume.getSize() returns the size in bytes
if (volumesSize < sourceSize) {
throw new InvalidParameterValueException("The configured root disk size (" + volumesSize +
" bytes) is smaller than the source volume size (" + sourceSize + " bytes).");
}
}

Copilot uses AI. Check for mistakes.
Comment on lines 108 to 109
StorPoolStorageAdaptor.resize( Long.toString(srcDisk.getVirtualSize()), dst.getPath());

Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

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

The resize operation is now only called for TemplateObjectTO instances, but there's no validation that srcDisk.getVirtualSize() is appropriate for the destination. Consider adding size validation before calling resize.

Suggested change
StorPoolStorageAdaptor.resize( Long.toString(srcDisk.getVirtualSize()), dst.getPath());
if (dst.getSize() != null && dst.getSize() < srcDisk.getVirtualSize()) {
final String error = "Destination size " + dst.getSize() + " is smaller than source virtual size " + srcDisk.getVirtualSize();
SP_LOG(error);
return new CopyCmdAnswer(error);
}
StorPoolStorageAdaptor.resize(Long.toString(srcDisk.getVirtualSize()), dst.getPath());

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

very sensible comment @Copilot, but it has nothing to do with the changes at hand.

@sureshanaparti
Copy link
Contributor

@blueorangutan package

StorPoolStorageAdaptor.resize( Long.toString(srcDisk.getVirtualSize()), dst.getPath());

if (dst instanceof TemplateObjectTO) {
StorPoolStorageAdaptor.resize( Long.toString(srcDisk.getVirtualSize()), dst.getPath());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
StorPoolStorageAdaptor.resize( Long.toString(srcDisk.getVirtualSize()), dst.getPath());
StorPoolStorageAdaptor.resize(Long.toString(srcDisk.getVirtualSize()), dst.getPath());

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, the second copilot remark seems as mute as the first one, I imaging that configureCustomRootDiskSize already does the checks sugested.

Copy link
Contributor

@nvazquez nvazquez 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 (haven't tested it though)

@nvazquez
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@nvazquez 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

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

@nvazquez
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-13981)

@sureshanaparti
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-13988)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 57703 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11351-t13988-kvm-ol8.zip
Smoke tests completed. 145 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

slavkap added 2 commits August 5, 2025 11:42
fix of deploy VM with a snapshot that is copied to another zone
fix of creating StorPool volume from a snapshot if the size in the
offering is bigger than the snapshot size
@slavkap slavkap force-pushed the fix-deploy-vm-from-copied-snapshot branch from 2652739 to 2d2990d Compare August 5, 2025 11:26
@sureshanaparti
Copy link
Contributor

@blueorangutan package

@sureshanaparti sureshanaparti added this to the 4.21.0 milestone Aug 6, 2025
@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.

@blueorangutan
Copy link

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

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@sureshanaparti sureshanaparti moved this to In Progress in Apache CloudStack 4.21.0 Aug 7, 2025
@sureshanaparti sureshanaparti merged commit dc5e475 into apache:main Aug 7, 2025
25 of 26 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Apache CloudStack 4.21.0 Aug 7, 2025
@blueorangutan
Copy link

[SF] Trillian test result (tid-14038)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 48918 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11351-t14038-kvm-ol8.zip
Smoke tests completed. 146 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Sep 4, 2025
…1351)

* Fix of deploy VM with a snapshot that is copied to another zone
* Fix of creating StorPool volume from a snapshot if the size in the
offering is bigger than the snapshot size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants