Skip to content

Compare volume size in bytes when changing to the same disk offering - #14750

Open
bhouse-nexthop wants to merge 1 commit into
apache:4.22from
bhouse-nexthop:volume-offering-resize-size-check
Open

bhouse-nexthop wants to merge 1 commit into
apache:4.22from
bhouse-nexthop:volume-offering-resize-size-check

Conversation

@bhouse-nexthop

Copy link
Copy Markdown
Contributor

Description

Fixes #14749

checkIfVolumeCanResizeWithNewDiskOffering shifted an already-bytes size by 30 again, so its "already having disk offering" guard never matched for custom-size offerings.

changeOfferingForVolume to the same custom offering before after
same size, same IOPS ran the full change path rejected: "already having disk offering"
same size, new IOPS allowed allowed
new size allowed allowed
compute-only offering (size taken from the volume) allowed allowed
  • Drop the second << 30.
  • Only reject when min/max IOPS are also unchanged.
  • Skip compute-only offerings (scale VM to the same custom service offering goes through here).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Bug Severity

  • Minor

How Has This Been Tested?

test result
VolumeApiServiceImplTest (150 tests, 5 new) pass
new rejection test against the unfixed code fails as expected

@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.33%. Comparing base (b56bbc2) to head (496f21b).
⚠️ Report is 2 commits behind head on 4.22.

Files with missing lines Patch % Lines
...n/java/com/cloud/storage/VolumeApiServiceImpl.java 60.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #14750   +/-   ##
=========================================
  Coverage     18.32%   18.33%           
- Complexity    16644    16660   +16     
=========================================
  Files          5939     5939           
  Lines        537787   537827   +40     
  Branches      65932    65939    +7     
=========================================
+ Hits          98544    98591   +47     
+ Misses       428033   428007   -26     
- Partials      11210    11229   +19     
Flag Coverage Δ
uitests 4.08% <ø> (ø)
unittests 19.42% <60.00%> (+<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.

@bhouse-nexthop

Copy link
Copy Markdown
Contributor Author

Tested on a KVM lab running a main (24.0) build that includes this change. Primary storage is Ceph RBD. The PR targets 4.22; changeOfferingForVolume is the same on both branches apart from this change.

Steps: attached a 1 GiB DATA volume on a custom-size disk offering to a Running VM, then changed it to the same offering, first with the same size, then with a new one.

Result: all checks passed.

Step Result
changeOfferingForVolume diskofferingid=<same offering> size=1 refused (431): Volume ... is already having disk offering <offering uuid>
changeOfferingForVolume diskofferingid=<same offering> size=2 accepted; the volume is 2 GiB

Before this change, the same-size call went through the full change path and returned success (#14749).

Not tested: offerings with IOPS or a hypervisor snapshot reserve, and the UI.

validateVolumeResizeWithNewDiskOfferingAndLoad converts a custom
offering's size from GiB to bytes, then checkIfVolumeCanResizeWithNewDiskOffering
shifted it by 30 again, so its "already having disk offering" guard
never matched for custom-size offerings.

| changeOfferingForVolume to the same custom offering | before | after |
|---|---|---|
| same size, same IOPS | ran the full change path | rejected: "already having disk offering" |
| same size, new IOPS | allowed | allowed |
| new size | allowed | allowed |
| compute-only offering (size taken from the volume) | allowed | allowed |

- Drop the second `<< 30` in the comparison.
- Only reject when min/max IOPS are also unchanged, so IOPS-only
  changes keep working.
- Skip compute-only offerings: their size always equals the volume's,
  and scale VM to the same custom service offering goes through here.
- Add unit tests for each row.

Signed-off-by: Brad House <bhouse@nexthop.ai>
@bhouse-nexthop
bhouse-nexthop force-pushed the volume-offering-resize-size-check branch from 496f21b to 2f150bf Compare December 1, 2026 16:04
bhouse-nexthop added a commit to bhouse-nexthop/cloudstack that referenced this pull request Dec 1, 2026
Review follow-up for apache#14750.

Signed-off-by: Brad House <bhouse@nexthop.ai>
(cherry picked from commit 2020a93f70fb8bdb0ddd70c6511764bff0640987)
bhouse-nexthop added a commit to bhouse-nexthop/cloudstack that referenced this pull request Dec 1, 2026
Review follow-up for apache#14750.

Signed-off-by: Brad House <bhouse@nexthop.ai>
(cherry picked from commit 8f4e66fcbb9b9fed67e5a1cfd43e20f14da6697f)

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.

2 participants