-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[VMware to KVM Migration] Fix unused convert env vars #11947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.22
Are you sure you want to change the base?
Conversation
|
@blueorangutan package |
|
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.22 #11947 +/- ##
=========================================
Coverage 17.59% 17.59%
- Complexity 15600 15602 +2
=========================================
Files 5910 5910
Lines 529755 529767 +12
Branches 64724 64726 +2
=========================================
+ Hits 93228 93235 +7
- Misses 426035 426038 +3
- Partials 10492 10494 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 15595 |
|
@blueorangutan package |
|
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15598 |
|
@blueorangutan test |
|
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-14752)
|
There was a problem hiding this 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 adds support for passing custom environment variables when executing scripts via the Script class, specifically to support virt-v2v instance conversions. The changes enable passing environment variables like TMPDIR and VIRT_V2V_TMPDIR to the virt-v2v command, which is necessary for indirect tool invocations (e.g., virt-v2v calling qemu-img).
Key changes:
- Extended the
Script.execute()method to accept an optional environment variables array - Modified the script execution logic to use
Runtime.exec()with environment variables when provided, falling back toProcessBuilderwhen no environment is specified - Updated
LibvirtConvertInstanceCommandWrapperto pass environment variables retrieved from the resource configuration
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| utils/src/main/java/com/cloud/utils/script/Script.java | Added new overloaded execute() methods to accept environment variables and modified execution logic to handle both ProcessBuilder and Runtime.exec() approaches |
| plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java | Updated to retrieve and conditionally pass environment variables to the script execution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (ArrayUtils.isEmpty(convertInstanceEnv)) { | ||
| script.execute(outputLogger); | ||
| } else { | ||
| script.execute(outputLogger, convertInstanceEnv); | ||
| } |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional check and branching can be simplified. The execute(outputLogger) method already calls execute(outputLogger, null), and the implementation handles null/empty arrays. You can directly call script.execute(outputLogger, convertInstanceEnv) without the conditional check, simplifying the code.
| if (ArrayUtils.isEmpty(convertInstanceEnv)) { | |
| script.execute(outputLogger); | |
| } else { | |
| script.execute(outputLogger, convertInstanceEnv); | |
| } | |
| script.execute(outputLogger, convertInstanceEnv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shwstppr @DaanHoogland I would prefer keeping it like this as script.execute(outputLogger); has 73 usages which we'll need passing null as the second parameter. I think keeping it like this it cleaner
| public String execute(OutputInterpreter interpreter, String[] environment) { | ||
| return executeInternal(interpreter, environment); | ||
| } | ||
|
|
||
| public String executeInternal(OutputInterpreter interpreter, String[] environment) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public String execute(OutputInterpreter interpreter, String[] environment) { | |
| return executeInternal(interpreter, environment); | |
| } | |
| public String executeInternal(OutputInterpreter interpreter, String[] environment) { | |
| public String execute(OutputInterpreter interpreter, String[] environment) { |
no need for the extra call on the stack, that I can see
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shwstppr @DaanHoogland I would prefer keeping it like this as script.execute(outputLogger); has 73 usages which we'll need passing null as the second parameter. I think keeping it like this it cleaner
|
@blueorangutan package |
|
@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✖️ debian ✔️ suse15. SL-JID 15891 |
|
@nvazquez Since this is for the 4.22.1 release, could you retarget the PR to the 4.22 branch? |
f2b6474 to
f893d3d
Compare
|
Thanks @rajujith retargeted to branch 4.22. @shwstppr @DaanHoogland I'll address your comments, thanks |
|
@blueorangutan package |
|
@blueorangutan package |
|
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16366 |
|
@blueorangutan test |
|
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian Build Failed (tid-15186) |
Description
This PR fixes unused convert env variables from PR #11594 on the KVM agents, when agent.properties set:
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?