Skip to content

Infer single conversion storage pool for VMware import#13235

Open
andrijapanicsb wants to merge 1 commit into
apache:mainfrom
andrijapanicsb:vddk-auto-select-single-pool
Open

Infer single conversion storage pool for VMware import#13235
andrijapanicsb wants to merge 1 commit into
apache:mainfrom
andrijapanicsb:vddk-auto-select-single-pool

Conversation

@andrijapanicsb
Copy link
Copy Markdown
Contributor

Description

This improves the VMware import workflow when forceconverttopool=true and the caller does not provide convertinstancepoolid.

Previously, the API always failed in that case, even when the destination environment had exactly one suitable primary storage pool. With this change, CloudStack infers that single suitable pool and proceeds. If no suitable pool exists, or if multiple suitable pools exist, the API still fails with a clear message so the caller can provide convertinstancepoolid explicitly.

No API parameters are added or removed.

API behavior

When forceconverttopool=true:

  • If convertinstancepoolid is supplied, the selected pool is used and validated as before.
  • If convertinstancepoolid is omitted and exactly one suitable KVM primary storage pool exists for the destination cluster or zone, that pool is used automatically.
  • If no suitable pool exists, the request fails with a clear error.
  • If multiple suitable pools exist, the request fails and asks the caller to provide convertinstancepoolid.

UI behavior

  • Direct conversion opens the primary storage selection path.
  • If the returned storage-pool list contains exactly one pool, the UI selects it automatically.
  • If multiple pools are available, the operator still chooses the intended pool.

Testing

  • mvn -pl server -am -Dtest=UnmanagedVMsManagerImplTest -DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false test

@andrijapanicsb andrijapanicsb requested review from harikrishna-patnala and nvazquez and removed request for nvazquez May 25, 2026 18:33
@codecov
Copy link
Copy Markdown

codecov Bot commented May 25, 2026

Codecov Report

❌ Patch coverage is 82.14286% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.10%. Comparing base (a0aafe2) to head (28a993f).

Files with missing lines Patch % Lines
.../apache/cloudstack/vm/UnmanagedVMsManagerImpl.java 82.14% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13235      +/-   ##
============================================
- Coverage     18.10%   18.10%   -0.01%     
- Complexity    16746    16751       +5     
============================================
  Files          6037     6037              
  Lines        542933   542974      +41     
  Branches      66487    66493       +6     
============================================
+ Hits          98283    98290       +7     
- Misses       433602   433641      +39     
+ Partials      11048    11043       -5     
Flag Coverage Δ
uitests 3.51% <ø> (-0.01%) ⬇️
unittests 19.26% <82.14%> (+<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.

@andrijapanicsb
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@andrijapanicsb 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.

@blueorangutan
Copy link
Copy Markdown

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

Copy link
Copy Markdown
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 improves the VMware→KVM import flow when forceconverttopool=true and no explicit convertinstancepoolid is provided, by inferring a single eligible primary storage pool when exactly one candidate exists. It also updates the UI to auto-select the only returned pool and to drive users into the primary-storage selection path when forced conversion is enabled.

Changes:

  • Server: infer an implicit conversion storage pool ID when forced conversion is enabled and exactly one eligible pool exists (cluster/zone scope).
  • Server: add unit tests covering implicit pool resolution behavior.
  • UI: centralize conversion-pool selection sync and auto-select the single available pool; auto-open primary storage selection for forced conversion/VDDK.

Reviewed changes

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

File Description
ui/src/views/tools/ImportUnmanagedInstance.vue Adds centralized pool-selection sync and auto-selection behavior; forces primary pool selection path when forceconverttopool / VDDK is enabled.
server/src/test/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImplTest.java Adds tests for implicit conversion storage pool resolution behavior.
server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java Adds logic to resolve an implicit conversion storage pool ID before validating the pool for forced conversion.

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

Comment on lines +1826 to +1833
List<StoragePoolVO> candidatePools = getImplicitForceConvertToPoolStoragePools(destinationCluster);
if (candidatePools.isEmpty()) {
logFailureAndThrowException(String.format("The parameter forceconverttopool is set to true, but no suitable primary storage pool was found in cluster %s",
destinationCluster.getName()));
}
if (candidatePools.size() > 1) {
logFailureAndThrowException(String.format("The parameter forceconverttopool is set to true, but multiple suitable primary storage pools were found in cluster %s. Please provide convertinstancepoolid.",
destinationCluster.getName()));
Comment on lines +1204 to +1207
selectPrimaryStorageForForcedConversion () {
this.selectedStorageOptionForConversion = 'primary'
this.showStoragePoolsForConversion = true
this.fetchStoragePoolsForConversion()
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