Skip to content

importVm: make clusterid optional - #14435

Open
rajujith wants to merge 1 commit into
apache:4.22from
rajujith:importvm-clusterid-optional
Open

rajujith wants to merge 1 commit into
apache:4.22from
rajujith:importvm-clusterid-optional

Conversation

@rajujith

Copy link
Copy Markdown
Contributor

Description

This PR makes the clusterid parameter of the importVm API optional.

ImportVmCmd extends ImportUnmanagedInstanceCmd and inherits clusterid with required = true, so every importVm call must pass a valid cluster UUID. However, for importsource=external, local and shared (importKvmInstance()), the value is never read:

  • For local / shared disk imports, the deployment plan is built from the storage pool's pod and cluster (and hostid for local storage), not from clusterid.
  • For external, the instance is fetched from the remote host given by host.

Only importsource=vmware and unmanaged (baseImportInstance()) use the cluster. Those paths already reject a missing cluster in basicAccessChecks(). This PR keeps that check and changes its message to name the clusterid parameter.

importUnmanagedInstance shares the same parameter field, so the API doc now lists clusterid as optional there too. The server still rejects a call without it, with an InvalidParameterValueException instead of the generic missing-parameter error, and the parameter description says when it is required.

Before this change, for example:

command=importVm&importsource=shared&hypervisor=kvm&diskpath=...&storageid=...&networkid=...&zoneid=...
-> 431: Unable to execute API command importvm due to missing parameter clusterid

After this change the call succeeds without clusterid. Requests that pass it are unaffected, so the UI (which always sends it) keeps working.

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?

Unit tests in UnmanagedVMsManagerImplTest (95 tests, all passing):

  • importFromLocalDisk / importFromsharedStorage now also check that getClusterId() is never called on the import path.
  • New testImportVmFromVmwareMissingClusterId and testImportVmFromUnmanagedMissingClusterId check that VMware and unmanaged imports without clusterid still fail with InvalidParameterValueException.

How did you try to break this feature and the system with this change?

Checked every caller of getClusterId() on the import commands: only baseImportInstance() (VMware/unmanaged) and listUnmanagedInstances read it, and both already check for null.

🤖 Generated with Claude Code

clusterid is inherited from importUnmanagedInstance as a required
parameter, but importVm with importsource external, local or shared
never reads it: the deployment plan for disk imports is derived from
the storage pool (and host for local storage). Make it optional at the
API layer. The VMware and unmanaged import paths still reject a missing
cluster in basicAccessChecks, now with a message naming the parameter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 18.03%. Comparing base (99f348e) to head (684e18f).

Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #14435   +/-   ##
=========================================
  Coverage     18.03%   18.03%           
- Complexity    16294    16295    +1     
=========================================
  Files          5937     5937           
  Lines        536832   536832           
  Branches      65793    65793           
=========================================
+ Hits          96802    96812   +10     
+ Misses       428977   428966   -11     
- Partials      11053    11054    +1     
Flag Coverage Δ
uitests 4.04% <ø> (ø)
unittests 19.10% <100.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.

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.

1 participant