Skip to content

MTV-4454 | Separate extra args for virt-v2v conversion and inspection#4509

Merged
mnecas merged 1 commit intokubev2v:mainfrom
yaacov:separate-virt-v2v-exra-args
Feb 3, 2026
Merged

MTV-4454 | Separate extra args for virt-v2v conversion and inspection#4509
mnecas merged 1 commit intokubev2v:mainfrom
yaacov:separate-virt-v2v-exra-args

Conversation

@yaacov
Copy link
Copy Markdown
Member

@yaacov yaacov commented Feb 1, 2026

Previously, VIRT_V2V_EXTRA_ARGS was applied to all virt-v2v commands including virt-v2v-inspector. This caused migrations to fail when using conversion-specific args like --parallel that are not recognized by virt-v2v-inspector.

This change introduces a new VIRT_V2V_INSPECTOR_EXTRA_ARGS setting and separates the argument handling:

  • VIRT_V2V_EXTRA_ARGS now applies only to virt-v2v and virt-v2v-in-place
  • VIRT_V2V_INSPECTOR_EXTRA_ARGS applies only to virt-v2v-inspector
  • Shared args (--root, --mac, --key) remain in addCommonArgs() for all

Breaking change: Users who relied on extra args being passed to both conversion and inspection will need to set both env vars.


  • adding new forlklift controller setting:
virt_v2v_inspector_extra_args:
                description: Additional arguments for virt-v2v-inspector
                example: --root first
                type: string
  • virt_v2v_extra_args works as expected ONLY for the virt-v2v executable

How to test:
a. set updated controller and virt-v2v images
b. update plan CRD
c. set virt_v2v_extra_args that only works with virt-v2v for example --parallel

the migration should pass


Ref: https://issues.redhat.com/browse/MTV-4454

Resolves: MTV-4454

Previously, VIRT_V2V_EXTRA_ARGS was applied to all virt-v2v commands
including virt-v2v-inspector. This caused migrations to fail when
using conversion-specific args like --parallel that are not recognized
by virt-v2v-inspector.

This change introduces a new VIRT_V2V_INSPECTOR_EXTRA_ARGS setting and
separates the argument handling:

- VIRT_V2V_EXTRA_ARGS now applies only to virt-v2v and virt-v2v-in-place
- VIRT_V2V_INSPECTOR_EXTRA_ARGS applies only to virt-v2v-inspector
- Shared args (--root, --mac, --key) remain in addCommonArgs() for all

Breaking change: Users who relied on extra args being passed to both
conversion and inspection will need to set both env vars.

Ref: https://issues.redhat.com/browse/MTV-4454

Resolves: MTV-4454

Signed-off-by: yaacov <yzamir@redhat.com>
@yaacov yaacov force-pushed the separate-virt-v2v-exra-args branch from 510384b to 6bf3f33 Compare February 1, 2026 11:22
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Feb 1, 2026

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 12.50000% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.91%. Comparing base (f1fe5d0) to head (6bf3f33).
⚠️ Report is 1668 commits behind head on main.

Files with missing lines Patch % Lines
pkg/virt-v2v/conversion/conversion.go 17.85% 22 Missing and 1 partial ⚠️
pkg/virt-v2v/config/variables.go 0.00% 8 Missing ⚠️
pkg/controller/plan/adapter/vsphere/builder.go 0.00% 4 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff            @@
##             main   #4509      +/-   ##
=========================================
- Coverage   15.45%   8.91%   -6.54%     
=========================================
  Files         112     468     +356     
  Lines       23377   53401   +30024     
=========================================
+ Hits         3613    4763    +1150     
- Misses      19479   48233   +28754     
- Partials      285     405     +120     
Flag Coverage Δ
unittests 8.91% <12.50%> (-6.54%) ⬇️

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.

@yaacov
Copy link
Copy Markdown
Member Author

yaacov commented Feb 1, 2026

@coderabbitai hi, can you review ?

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 1, 2026

@yaacov: I'll review the changes in this PR right away.


🧠 Learnings used
Learnt from: yaacov
Repo: kubev2v/forklift PR: 3204
File: operator/.upstream_manifests:156-181
Timestamp: 2025-10-16T14:11:57.112Z
Learning: Repo: kubev2v/forklift — Maintainer yaacov prefers not to create GitHub follow-up issues (e.g., for re-tightening ForkliftController CRD types after temporary relaxation); such work is tracked in a different system. In future reviews, acknowledge and proceed without proposing GitHub issue creation.

Learnt from: yaacov
Repo: kubev2v/forklift PR: 3204
File: operator/.upstream_manifests:6770-6772
Timestamp: 2025-10-16T18:19:40.853Z
Learning: Repo: kubev2v/forklift — For PRs relaxing ForkliftController CRD types (e.g., accepting booleans/ints/strings), do not modify or expand the example ForkliftController resource in operator/.upstream_manifests within that PR. Keep examples as-is and handle any exposure/consistency adjustments (e.g., listing feature_* flags in samples/CSV) in a separate, dedicated follow-up. Avoid creating GitHub issues for such follow-ups as they’re tracked elsewhere.

Learnt from: yaacov
Repo: kubev2v/forklift PR: 2561
File: Makefile:0-0
Timestamp: 2025-08-19T10:02:47.617Z
Learning: User yaacov prefers to defer security hardening improvements like checksum verification to follow-up PRs rather than expanding the scope of cleanup-focused PRs.

Learnt from: yaacov
Repo: kubev2v/forklift PR: 3204
File: operator/.downstream_manifests:138-138
Timestamp: 2025-10-16T13:44:49.727Z
Learning: Repo: kubev2v/forklift — For PRs that relax ForkliftController CRD types (e.g., boolean-like and counting fields), maintainers prefer no field-name changes. Typos like controller_snapshot_removal_timeout_minuts should be tracked in a separate follow-up issue rather than addressed in the same PR.

Learnt from: yaacov
Repo: kubev2v/forklift PR: 2464
File: Makefile:138-147
Timestamp: 2025-08-13T03:31:49.934Z
Learning: In the kubev2v/forklift project, PRs should maintain focused scope and avoid mixing concerns. For example, adding a new environment variable should not be combined with larger refactoring efforts in the same PR, even if both changes affect the same file.

Learnt from: yaacov
Repo: kubev2v/forklift PR: 2882
File: operator/config/rbac/role.yaml:42-47
Timestamp: 2025-09-18T13:45:04.028Z
Learning: In the yaacov/forklift project, comprehensive fixes (like RBAC permission cleanup) are preferred to be done in dedicated PRs rather than mixed with feature additions, to ensure consistency across the codebase.

Learnt from: yaacov
Repo: kubev2v/forklift PR: 2540
File: pkg/controller/plan/adapter/vsphere/builder.go:694-699
Timestamp: 2025-08-18T13:45:08.364Z
Learning: The user yaacov prefers not to change existing behavior within the scope of a current PR when additional validation or safety checks are identified, and instead prefers to create follow-up issues to address such improvements separately.

Learnt from: yaacov
Repo: kubev2v/forklift PR: 2690
File: operator/config/crd/bases/forklift.konveyor.io_forkliftcontrollers.yaml:84-88
Timestamp: 2025-09-02T17:01:19.057Z
Learning: The maintainer yaacov prefers to keep field names as-is when documenting existing ForkliftController CRD fields in documentation PRs, rather than making consistency improvements that would require operator code changes. Field name standardization should be handled in separate PRs focused on operator changes.

Learnt from: yaacov
Repo: kubev2v/forklift PR: 3204
File: operator/.upstream_manifests:156-181
Timestamp: 2025-10-16T13:46:22.273Z
Learning: Repo: kubev2v/forklift — When temporarily relaxing ForkliftController CRD types to accept booleans/ints alongside strings, maintainers prefer not to add runtime normalization or extra checks in roles/templates. Keep changes limited to schema, treat this as temporary compatibility, and plan to re-tighten types in a follow-up release.

Learnt from: yaacov
Repo: kubev2v/forklift PR: 3204
File: operator/.kustomized_manifests:124-153
Timestamp: 2025-10-16T13:44:44.405Z
Learning: Repo: kubev2v/forklift — For CRD unions, do not suggest OpenAPI oneOf/anyOf; Kubernetes structural schemas reject these for type unions. Use x-kubernetes-int-or-string for numeric unions and, for boolean-like ForkliftController flags (feature_* and controller_* plus k8s_cluster and virt_v2v_dont_request_kvm), rely on x-kubernetes-preserve-unknown-fields to tolerate both booleans and strings while documentation continues to prefer "true"/"false".
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 1, 2026

📝 Walkthrough

Walkthrough

This pull request adds virt-v2v-inspector extra arguments configuration throughout the Forklift codebase, introduces HyperV-related resource limit and request fields to ForkliftController CRD, expands RBAC permissions for CSI drivers, adds a suggestion field to status conditions in multiple CRDs, and refactors conversion argument handling to distinguish between conversion and inspection paths.

Changes

Cohort / File(s) Summary
ForkliftController CRD Updates
operator/.downstream_manifests, operator/.kustomized_manifests, operator/.upstream_manifests, operator/config/crd/bases/forklift.konveyor.io_forkliftcontrollers.yaml
Added new field virt_v2v_inspector_extra_args to spec; updated virt_v2v_extra_args description from "Additional arguments for virt-v2v" to "Additional arguments for virt-v2v conversion"; introduced HyperV-related fields (hyperv_container_limits_cpu, hyperv_container_limits_memory, hyperv_container_requests_cpu, hyperv_container_requests_memory, hyperv_provider_server_fqin); added suggestion field to status condition definitions.
ClusterServiceVersion UI Descriptors
operator/config/manifests/bases/forklift-operator.clusterserviceversion.yaml, operator/streams/downstream/mtv-operator.clusterserviceversion.yaml, operator/streams/upstream/forklift-operator.clusterserviceversion.yaml
Added new descriptor entry for virt_v2v_inspector_extra_args with displayName and description; renamed existing virt-v2v descriptor description to reference "conversion".
RBAC Permissions
operator/.downstream_manifests, operator/.upstream_manifests
Extended ClusterRole definitions (forklift-api-role, forklift-controller-role, manager-role) to include csidrivers access under storage.k8s.io API group.
Operator Role Configuration
operator/roles/forkliftcontroller/defaults/main.yml, operator/roles/forkliftcontroller/templates/controller/deployment-controller.yml.j2
Added virt_v2v_inspector_extra_args environment variable configuration and deployment template reference.
Settings and Config
pkg/settings/migration.go, pkg/virt-v2v/config/variables.go
Added VirtV2vInspectorExtraArgs constant and struct field to Migration; added InspectorExtraArgs field and parsing logic to AppConfig with environment variable reading and JSON encoding.
Conversion Logic Refactoring
pkg/controller/plan/adapter/vsphere/builder.go, pkg/virt-v2v/conversion/conversion.go
Introduced separate helper functions addConversionExtraArgs and addInspectorExtraArgs to distinguish argument application; added inspection-specific helper addVirtV2vVsphereArgsForInspection; updated call sites in inspection and conversion paths to use appropriate handlers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • PR #2690: Modifies ForkliftController CRD spec with additional controller settings and properties.
  • PR #3204: Updates ForkliftController CRD and ClusterServiceVersion UI descriptors for spec field exposure.
  • PR #2779: Extends virt-v2v configuration and conversion argument builders with new environment variable handling.

Suggested reviewers

  • mnecas
  • mrnold
  • Hazanel

Poem

🐰 The inspector hops with extra args in tow,
HyperV fields now bloom and grow,
CSI drivers granted access wide,
Suggestions in conditions now reside,
Conversion paths split clean and neat,
A virt-v2v refactor, complete! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: separating extra arguments for virt-v2v conversion and inspection into distinct environment variables.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description clearly describes the changeset: introducing separate environment variables for virt-v2v conversion and inspection extra arguments to fix migration failures.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
pkg/virt-v2v/config/variables.go (1)

15-172: ⚠️ Potential issue | 🟠 Major

Fail fast on invalid V2V_inspector_extra_args JSON (don’t silently ignore).
Right now a malformed value is only printed and then ignored, which can hide misconfiguration. Return the parse error from Load() so startup fails with a clear message, and add tests for valid/invalid JSON inputs.

💡 Proposed fix (propagate parse error)
- s.InspectorExtraArgs = s.getInspectorExtraArgs()
+ if s.InspectorExtraArgs, err = s.getInspectorExtraArgs(); err != nil {
+     return err
+ }

-func (s *AppConfig) getInspectorExtraArgs() []string {
+func (s *AppConfig) getInspectorExtraArgs() ([]string, error) {
 	var extraArgs []string
 	if envExtraArgs, found := os.LookupEnv(EnvInspectorExtraArgsName); found && envExtraArgs != "" {
 		if err := json.Unmarshal([]byte(envExtraArgs), &extraArgs); err != nil {
-			fmt.Printf("Failed to parse %s: %v\n", EnvInspectorExtraArgsName, err)
-			return nil
+			return nil, fmt.Errorf("parse %s: %w", EnvInspectorExtraArgsName, err)
 		}
 	}
-	return extraArgs
+	return extraArgs, nil
 }

As per coding guidelines: Error Handling: No silent failures. Errors must be checked, wrapped with context, and propagated; coverage: Make sure that the code has unit tests.

operator/.downstream_manifests (1)

7636-7641: ⚠️ Potential issue | 🟡 Minor

Align CSV description with CRD wording.

Line 7636 mentions only OVA, while the CRD description (Line 203‑204) includes HyperV. Suggest mirroring that wording for consistency.

Proposed fix
-      - description: Enable OVA appliance management endpoints (default false)
+      - description: Enable OVF-based appliance management endpoints (OVA, HyperV) (default false)
🤖 Fix all issues with AI agents
In `@operator/.downstream_manifests`:
- Around line 6733-6735: Update the RBAC rule that currently groups
"storageclasses" and "csidrivers" under the same verbs block: split the rule so
"storageclasses" retains "list" and "watch" (for the informer) while
"csidrivers" is limited to "get" only (since the controller only calls r.Get()
to verify the SMB CSI driver). Locate the rule containing the "storageclasses"
and "csidrivers" resources and adjust the verbs for "csidrivers" to only include
"get" (or create a separate rule for csidrivers with verbs: ["get"]).

In `@operator/.upstream_manifests`:
- Around line 249-268: This change mixes HyperV-specific config keys
(hyperv_container_limits_cpu, hyperv_container_limits_memory,
hyperv_container_requests_cpu, hyperv_container_requests_memory,
hyperv_provider_server_fqin) into a PR meant for virt-v2v args separation;
remove these hyperv_* entries from this PR's diff and extract them into a
separate focused PR that only adds the HyperV resource/image fields, leaving the
virt-v2v args changes isolated (search for the keys hyperv_container_limits_cpu,
hyperv_container_limits_memory, hyperv_container_requests_cpu,
hyperv_container_requests_memory, hyperv_provider_server_fqin to locate and
remove/extract).
- Line 7636: The CSV description string "Enable OVA appliance management
endpoints (default false)" is inconsistent with the CRD description that
references OVF-based endpoints (OVA, HyperV); update the CSV description (the
descriptor containing "Enable OVA appliance management endpoints") to match the
CRD wording — e.g., change it to "Enable OVF‑based appliance management
endpoints (OVA, HyperV) (default false)" or the exact phrase used in the CRD so
both documents use identical terminology.

In `@pkg/controller/plan/adapter/vsphere/builder.go`:
- Around line 299-305: Add a unit test that configures
settings.Settings.Migration.VirtV2vInspectorExtraArgs and asserts the Pod
environment builder includes an env var with Name "V2V_inspector_extra_args" and
Value equal to that setting; update the existing PodEnvironment tests (the test
that exercises the Pod environment builder / function that produces core.EnvVar
entries) to set the Migration.VirtV2vInspectorExtraArgs value, call the same
builder used in builder.go, and add an assertion verifying the presence and
value of the "V2V_inspector_extra_args" env var so the new lines are covered.

In `@pkg/settings/migration.go`:
- Around line 224-231: Add unit tests for the VirtV2vInspectorExtraArgs behavior
in pkg/settings/migration.go: write tests that set/clear the environment
variable name VirtV2vInspectorExtraArgs and assert that the function that
populates r.VirtV2vInspectorExtraArgs returns the JSON "[]" default when the env
var is unset, returns a JSON array encoding of strings (use strings.Fields
semantics) when the env var contains space-separated args, and treats an
explicitly empty env var value as the default/empty-array case; locate the code
paths by referencing the symbol VirtV2vInspectorExtraArgs and the assignment to
r.VirtV2vInspectorExtraArgs to ensure tests exercise the json.Marshal branch and
the default branch.

In `@pkg/virt-v2v/conversion/conversion.go`:
- Around line 94-106: Add unit tests for Conversion.addConversionExtraArgs,
Conversion.addInspectorExtraArgs and addVirtV2vVsphereArgsForInspection: create
a test table with cases where the respective
ExtraArgs/InspectorExtraArgs/VSphere args are nil (assert AddExtraArgs is not
called) and non-nil (assert AddExtraArgs is called with the exact slice), and
add a case to verify conversion vs inspector separation (e.g., set both
ExtraArgs and InspectorExtraArgs and assert only the target helper calls
AddExtraArgs). Use a small fake/mocking implementation of utils.CommandBuilder
that records AddExtraArgs invocations and compare recorded args to expected
values to validate behavior. Ensure tests live alongside conversion.go tests and
cover both nil and non-nil paths.
- Around line 222-247: The two functions addVirtV2vVsphereArgsForInspection and
addVirtV2vVsphereArgs share the same libvirt/common/VDDK argument assembly;
extract that shared logic into a helper (e.g., buildVsphereArgsCommon or
addVsphereBaseArgs) that accepts flags to control the two differences (whether
to call addConversionExtraArgs and whether VDDK config respects extra-args
override), then have addVirtV2vVsphereArgsForInspection call that helper with
parameters to skip addConversionExtraArgs and to always apply VddkConfFile,
while addVirtV2vVsphereArgs calls it with the original behavior; reference
existing symbols addCommonArgs, addConversionExtraArgs, VddkLibDir,
VddkConfFile, Fingerprint, LibvirtUrl, SecretKey, HostName, and VmName when
moving logic so behavior remains identical.

Comment on lines +222 to +247
// addVirtV2vVsphereArgsForInspection adds vSphere-specific args WITHOUT conversion extra args
// This is used for remote inspection where we want inspector-specific args instead
func (c *Conversion) addVirtV2vVsphereArgsForInspection(cmd utils.CommandBuilder) (err error) {
cmd.AddArg("-i", "libvirt").
AddArg("-ic", c.LibvirtUrl).
AddArg("-ip", c.SecretKey).
AddArg("--hostname", c.HostName)

err = c.addCommonArgs(cmd)
if err != nil {
return err
}
// Note: NO addConversionExtraArgs here - this is for inspection
if info, err := os.Stat(c.VddkLibDir); err == nil && info.IsDir() {
cmd.AddArg("-it", "vddk")
cmd.AddArg("-io", fmt.Sprintf("vddk-libdir=%s", c.VddkLibDir))
cmd.AddArg("-io", fmt.Sprintf("vddk-thumbprint=%s", c.Fingerprint))
// Always use vddk-config for inspection if it exists (no extra args override)
if _, err := os.Stat(c.VddkConfFile); !errors.Is(err, os.ErrNotExist) {
cmd.AddArg("-io", fmt.Sprintf("vddk-config=%s", c.VddkConfFile))
}
}
cmd.AddPositional("--")
cmd.AddPositional(c.VmName)
return nil
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider extracting shared vSphere argument building logic.

addVirtV2vVsphereArgsForInspection duplicates most of addVirtV2vVsphereArgs with intentional differences in:

  1. No addConversionExtraArgs call
  2. VDDK config always applied without extra args override check

While the separation is correct for the PR's objectives, the shared logic (libvirt args, common args, VDDK setup) could be extracted to a helper to reduce duplication. This can be addressed in a follow-up if desired.

🤖 Prompt for AI Agents
In `@pkg/virt-v2v/conversion/conversion.go` around lines 222 - 247, The two
functions addVirtV2vVsphereArgsForInspection and addVirtV2vVsphereArgs share the
same libvirt/common/VDDK argument assembly; extract that shared logic into a
helper (e.g., buildVsphereArgsCommon or addVsphereBaseArgs) that accepts flags
to control the two differences (whether to call addConversionExtraArgs and
whether VDDK config respects extra-args override), then have
addVirtV2vVsphereArgsForInspection call that helper with parameters to skip
addConversionExtraArgs and to always apply VddkConfFile, while
addVirtV2vVsphereArgs calls it with the original behavior; reference existing
symbols addCommonArgs, addConversionExtraArgs, VddkLibDir, VddkConfFile,
Fingerprint, LibvirtUrl, SecretKey, HostName, and VmName when moving logic so
behavior remains identical.

Copy link
Copy Markdown
Member

@mnecas mnecas left a comment

Choose a reason for hiding this comment

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

lgtm

@mnecas mnecas merged commit f4f57c9 into kubev2v:main Feb 3, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants