Skip to content

Fix two lines changed by mistake in the 4.22 merge - #14767

Open
bhouse-nexthop wants to merge 1 commit into
apache:mainfrom
bhouse-nexthop:fix-merge-82bfa9fb3f-leftovers
Open

bhouse-nexthop wants to merge 1 commit into
apache:mainfrom
bhouse-nexthop:fix-merge-82bfa9fb3f-leftovers

Conversation

@bhouse-nexthop

@bhouse-nexthop bhouse-nexthop commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes two lines on main that the 4.22 merge 82bfa9f changed by mistake.

file change why
ApiResponseHelper Boolean.getBoolean(value) -> Boolean.parseBoolean(value) getBoolean reads a system property, so snapshots on storage with storage-system snapshot support were reported with the Image role
VolumeApiServiceImpl UseHttpsToUpload.value() -> UseHttpsToUpload.valueIn(zoneId) restores #11539 for volume uploads; the zone value was ignored
VolumeApiServiceImpl {code}...{code} -> {@code ...} in a Javadoc broken tag from the same merge

Related: #14760 (duplicated block from the same merge).

Fixes: #14766

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

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

  • New ApiResponseHelperTest cases for getDataStoreRole: capability true, TRUE, True -> Primary; false, yes, empty, and a null or empty capabilities map -> Image. The true cases fail before the fix.
  • ApiResponseHelperTest and VolumeApiServiceImplTest pass.
  • No unit test for the uploadVolume line: the method needs the DB transaction, call context and a private validation step. It is the same call TemplateManagerImpl already makes.

@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 20.92%. Comparing base (2737087) to head (888bd33).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...n/java/com/cloud/storage/VolumeApiServiceImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #14767      +/-   ##
============================================
+ Coverage     20.80%   20.92%   +0.12%     
- Complexity    20919    21150     +231     
============================================
  Files          6053     6057       +4     
  Lines        548451   549556    +1105     
  Branches      78719    73477    -5242     
============================================
+ Hits         114128   115018     +890     
- Misses       420958   421086     +128     
- Partials      13365    13452      +87     
Flag Coverage Δ
uitests 3.86% <ø> (ø)
unittests 22.37% <50.00%> (+0.12%) ⬆️

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.

@@ -840,7 +840,7 @@ public static DataStoreRole getDataStoreRole(Snapshot snapshot, SnapshotDataStor

if (mapCapabilities != null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

mapCapabilities can be empty, in this case get() and parseBoolean() calls do not add much value. While the performance impact is negligible, using a utility method such as isNotEmpty() would avoid executing the block when the map is either null or empty.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'd rather leave this line as it is. The if (mapCapabilities != null) block is unchanged from before the merge; this PR only restores parseBoolean. The result is already the same either way: with an empty map, get() returns null and parseBoolean(null) is false, so it falls through to Image. I added a test for the null and empty map cases (see the test thread).


String ssvmUrlDomain = _configDao.getValue(Config.SecStorageSecureCopyCert.key());
String protocol = UseHttpsToUpload.value() ? "https" : "http";
String protocol = UseHttpsToUpload.valueIn(zoneId) ? "https" : "http";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please consider using the constants for "https" and "http" instead of hardcoded string literals.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I kept the literals on purpose. This PR only puts back valueIn(zoneId) on a line that already had them, and the same line in TemplateManagerImpl.registerPostUploadInternal uses the same literals (UseHttpsToUpload.valueIn(...) ? "https" : "http"). HttpConstants in utils has HTTPS but no HTTP, so using constants here means adding one and changing both upload paths. I'd keep that out of this fix.

@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

Tested on a KVM lab running a main build that includes this change. One zone with a secondary storage VM.

Steps: I called getUploadParamsForVolume (QCOW2) twice. Each time the zone value of use.https.to.upload was set opposite to the global value.

Result: all checks passed.

Global Zone postURL scheme
true false http
false true https

The scheme follows the zone value both times. Before this change it followed the global value, so the two calls would have given https and then http (#14766).

Not tested: the getDataStoreRole line. Ceph RBD on the default primary driver does not report the storage-system snapshot capability, so the lab cannot reach that line; the new unit tests cover it. The actual upload was not tested either.

The merge 82bfa9f left these on main; neither parent had them.

- ApiResponseHelper.getDataStoreRole: Boolean.getBoolean(value) reads
  a JVM system property, so it was always false and snapshots on
  storage with storage-system snapshot support got the Image role.
  Use Boolean.parseBoolean(value), same as main had (new Boolean).
- VolumeApiServiceImpl.uploadVolume: restore
  UseHttpsToUpload.valueIn(zoneId) from apache#11539; the zone value was
  ignored for volume uploads.
- VolumeApiServiceImpl: fix {code}...{code} Javadoc to {@code ...}.
- Add getDataStoreRole tests in ApiResponseHelperTest.

Signed-off-by: Brad House <bhouse@nexthop.ai>
@bhouse-nexthop
bhouse-nexthop force-pushed the fix-merge-82bfa9fb3f-leftovers branch from 2d9e488 to 888bd33 Compare November 30, 2026 02:51

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.

Merge of 4.22 into main left Boolean.getBoolean and a non-zone use.https.to.upload lookup

2 participants