Skip to content

Deal with Storage Manager tech debt - #13598

Draft
DaanHoogland wants to merge 1 commit into
mainfrom
ghi12316-storageManagerTechDebt
Draft

Deal with Storage Manager tech debt#13598
DaanHoogland wants to merge 1 commit into
mainfrom
ghi12316-storageManagerTechDebt

Conversation

@DaanHoogland

Copy link
Copy Markdown
Contributor

Description

This PR...

Fixes: #12316

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?

@DaanHoogland

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

CopilotAI left a comment

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.

Pull request overview

This PR addresses tech debt in the storage management area (Fixes #12316) by removing unused code paths, tightening type usage, and consolidating configuration access via ConfigKey/ConfigurationManager while standardizing logging.

Changes:

  • Refactors StorageManagerImpl to remove unused methods/fields, reduce raw types, and modernize logging and collection checks.
  • Moves several global configuration keys from Config enum usage toward ConfigurationManager/StorageManagerConfigKeys and updates call sites (including Swift/S3 drivers).
  • Cleans up API command/service signatures to align with the refactors (generics, removed obsolete checked exceptions, minor code simplifications).

Reviewed changes

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

Show a summary per file
FileDescription
server/src/main/java/com/cloud/storage/StorageManagerImpl.javaCore refactor: remove unused code, generics cleanup, logging updates, config usage changes.
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.javaExposes newly added ConfigurationManager config keys via getConfigKeys().
server/src/main/java/com/cloud/configuration/Config.javaRemoves several config enum entries migrated to ConfigKey locations.
plugins/storage/image/swift/src/main/java/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.javaUses ConfigurationManagerConfigKey for extract URL expiry; logging/generics cleanup.
plugins/storage/image/s3/src/main/java/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.javaUses ConfigurationManagerConfigKey for extract URL expiry; logging cleanup.
engine/storage/cache/src/main/java/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.javaSwitches expunge worker count to ConfigurationManager.ExpungeWorkers.
engine/components-api/src/main/java/com/cloud/storage/StorageManager.javaRemoves unused API surface; adds disk throttling ConfigKeys and minor boolean cleanup.
engine/components-api/src/main/java/com/cloud/configuration/ConfigurationManager.javaIntroduces expunge/extract URL related ConfigKeys.
api/src/main/java/org/apache/cloudstack/api/command/admin/swift/AddSwiftCmd.javaSimplifies execute flow after service signature change.
api/src/main/java/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.javaAdjusts details map typing to reduce raw/unchecked usage.
api/src/main/java/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.javaFormatting cleanup and removes obsolete exception handling.
api/src/main/java/org/apache/cloudstack/api/command/admin/storage/AddImageStoreS3CMD.javaSimplifies execute flow and generics; API command annotation adjusted.
api/src/main/java/org/apache/cloudstack/api/command/admin/storage/AddImageStoreCmd.javaSimplifies details extraction loop and execute flow.
api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.javaSimplifies execute flow after service signature change.
api/src/main/java/com/cloud/storage/StorageService.javaTightens generics and removes obsolete checked exceptions from API surface.

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

Comment on lines +57 to +58
@APICommand(name = "addImageStoreS3", description = "Adds S3 Image Store", responseObject = ImageStoreResponse.class,
since = "4.7.0", responseHasSensitiveInfo = false)
Comment on lines 4477 to 4481
if (logger.isDebugEnabled()) {
logger.debug("Failed to add object store: " + e.getMessage(), e);
logger.debug("Failed to add object store: {}", e.getMessage(), e);
}
throw new CloudRuntimeException("Failed to add object store: " + e.getMessage(), e);
throw new CloudRuntimeException("Failed to add object store: {}" + e.getMessage(), e);
}
Comment on lines 4387 to +4390
DataStoreDownloadFollowRedirects,
AllowVolumeReSizeBeyondAllocation,
StoragePoolHostConnectWorkers,
ObjectStorageCapacityThreshold,
COPY_TEMPLATES_FROM_OTHER_SECONDARY_STORAGES
ObjectStorageCapacityThreshold
Comment on lines +244 to +248
ConfigKey<Integer> VmDiskThrottlingIopsReadRate = new ConfigKey<>(
Integer.class,
"vm.disk.throttling.iops_read_rate",
"Storage",
"0",
Comment on lines +253 to +257
ConfigKey<Integer> VmDiskThrottlingIopsWriteRate = new ConfigKey<>(
Integer.class,
"vm.disk.throttling.iops_write_rate",
"Storage",
"0",
Comment on lines +262 to +266
ConfigKey<Integer> VmDiskThrottlingBytesReadRate = new ConfigKey<>(
Integer.class,
"vm.disk.throttling.bytes_read_rate",
"Storage",
"0",
ConfigKey.CATEGORY_ADVANCED,
Integer.class,
"expunge.workers",
"10",
}

HypervisorType hypervisorType = HypervisorType.KVM;
HypervisorType hypervisorType; // defaults to HypervisorType.KVM

if (sPool.getPoolType() == StoragePoolType.DatastoreCluster) {
// FR41 yet to handle on failure of deletion of any of the child storage pool
// FR41 yet to handle on failure of deletion any child storage pool
@codecov

codecovBot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 24.62312% with 150 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.50%. Comparing base (38b674f) to head (7864f0d).
⚠️ Report is 13 commits behind head on main.

Files with missing linesPatch %Lines
...ain/java/com/cloud/storage/StorageManagerImpl.java21.83%108 Missing and 3 partials ⚠️
.../api/command/admin/storage/AddImageStoreS3CMD.java0.00%9 Missing ⚠️
...loudstack/api/command/admin/swift/AddSwiftCmd.java0.00%9 Missing ⚠️
...api/command/admin/host/AddSecondaryStorageCmd.java0.00%8 Missing ⚠️
...ge/datastore/driver/SwiftImageStoreDriverImpl.java0.00%4 Missing ⚠️
...ck/api/command/admin/storage/AddImageStoreCmd.java72.72%3 Missing ⚠️
...orage/datastore/driver/S3ImageStoreDriverImpl.java0.00%3 Missing ⚠️
...pi/command/admin/storage/UpdateStoragePoolCmd.java0.00%1 Missing ⚠️
...rc/main/java/com/cloud/storage/StorageManager.java83.33%0 Missing and 1 partial ⚠️
...storage/cache/manager/StorageCacheManagerImpl.java0.00%1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #13598 +/- ##
============================================
+ Coverage 19.47% 19.50% +0.02% - Complexity 19404 19440 +36 
============================================
Files 6303 6303 Lines 569237 569111 -126 Branches 69781 69755 -26 ============================================
+ Hits 110870 111010 +140 + Misses 446234 445957 -277 - Partials 12133 12144 +11 
FlagCoverage Δ
uitests3.41% <ø> (ø)
unittests20.78% <24.62%> (+0.03%)⬆️

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.

@blueorangutan

Copy link
Copy Markdown

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

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate FailedQuality Gate failed

Failed conditions
8.5% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube Cloud

@github-actions

Copy link
Copy Markdown

🔴 Test Coverage Grade: D — Marginal

MetricValue
Line coverage24.31%
Branch coverage18.45%

Grade Scale

GradeLine CoverageMeaning
🟢 A≥ 80%Excellent - this code sleeps well at night 😴
🟡 B60-79%Good - almost there, don't stop now 😉
🟠 C40-59%Acceptable - your code is wearing a seatbelt, but no airbags 😬
🔴 D20-39%Marginal - boldly shipping where no test has gone before 🖖
⛔ F< 20%Failing - tests? what tests? 🔥

Branch coverage is shown as a secondary signal. Grade is determined by line coverage.
View full Actions run

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
ImageStore result = _storageService.discoverImageStore(null, getUrl(), "NFS", getZoneId(), getDetails());
ImageStoreResponse storeResponse = null;
if (result != null ) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@DaanHoogland can we invert the logic to reduce identation?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

not my style, but I’ll have to revisit anyway because of conflicts :/ later..

throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
ImageStore result = _storageService.discoverImageStore(getName(), getUrl(), getProviderName(), getZoneId(), getDetails());
ImageStoreResponse storeResponse;
if (result != null) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same here

throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
ImageStore result = _storageService.discoverImageStore(null, null, "S3", null, dm);
ImageStoreResponse storeResponse;
if (result != null) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same here

throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
ImageStore result = _storageService.discoverImageStore(null, getUrl(), "Swift", null, dm);
ImageStoreResponse storeResponse;
if (result != null) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same here

@DaanHoogland
DaanHoogland marked this pull request as draft July 20, 2026 11:27
@DaanHooglandDaanHoogland self-assigned this Jul 20, 2026
Sign up for freeto 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.

deal with tech debt in StorageManager(Impl)

4 participants

@DaanHoogland@blueorangutan@GaOrtiga