Skip to content

Conversation

@shwstppr
Copy link
Contributor

@shwstppr shwstppr commented Sep 11, 2025

Description

Add statuses action in extensions to report VM power states

This PR introduces support for retrieving the power state of all VMs on a host directly from an extension using the new statuses action.
When available, this provides a single aggregated response, reducing the need for multiple calls.

If the extension does not implement statuses, the server will gracefully fall back to querying individual VMs using the existing status action.

This helps with updating the host in CloudStack after out-of-band migrations for the VM.

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):

extension-powersync-oobmigrate.mp4

How Has This Been Tested?

Tested with an env having 2x Proxmox hosts. Power sync worked after oob power operations on the VM. Also, host gets updated in CloudStack after oob migration from Proxmox (video above).

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

@codecov
Copy link

codecov bot commented Sep 11, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.56%. Comparing base (50fe265) to head (fccd6bb).
⚠️ Report is 3 commits behind head on 4.22.

Files with missing lines Patch % Lines
...al/provisioner/ExternalPathPayloadProvisioner.java 88.88% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #11619      +/-   ##
============================================
+ Coverage     17.55%   17.56%   +0.01%     
- Complexity    15535    15547      +12     
============================================
  Files          5909     5909              
  Lines        529053   529140      +87     
  Branches      64619    64629      +10     
============================================
+ Hits          92879    92952      +73     
- Misses       425719   425731      +12     
- Partials      10455    10457       +2     
Flag Coverage Δ
uitests 3.58% <ø> (-0.01%) ⬇️
unittests 18.63% <88.88%> (+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.

@boring-cyborg boring-cyborg bot added the Python Warning... Python code Ahead! label Sep 11, 2025
@shwstppr shwstppr changed the title extension/proxmox: improve host vm power reporting extension: improve host vm power reporting Sep 11, 2025
@shwstppr shwstppr requested a review from Copilot September 11, 2025 14:22
Copy link
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 introduces a new statuses action to extensions that allows querying the power state of all VMs on a host with a single call, improving efficiency over individual VM queries. The server gracefully falls back to the existing status action when the extension doesn't support the new functionality.

Key changes:

  • Add statuses action implementation to existing extensions (Proxmox, HyperV, sample provisioner)
  • Implement Java logic to use batch VM status retrieval with fallback to individual calls
  • Add comprehensive test coverage for the new functionality

Reviewed Changes

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

Show a summary per file
File Description
scripts/vm/hypervisor/external/provisioner/provisioner.sh Adds sample statuses action implementation that returns "Not supported" error
plugins/hypervisors/external/src/main/java/org/apache/cloudstack/hypervisor/external/provisioner/ExternalPathPayloadProvisioner.java Implements batch VM status retrieval with fallback logic and modernizes JSON parsing
plugins/hypervisors/external/src/test/java/org/apache/cloudstack/hypervisor/external/provisioner/ExternalPathPayloadProvisionerTest.java Adds comprehensive test coverage for new batch status functionality
extensions/Proxmox/proxmox.sh Implements statuses action to query all VMs via Proxmox API
extensions/HyperV/hyperv.py Implements statuses action using PowerShell Get-VM command

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}
try {
JsonObject jsonObj = new JsonParser().parse(response).getAsJsonObject();
JsonObject jsonObj = JsonParser.parseString(response).getAsJsonObject();
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

The deprecated new JsonParser().parse() method has been replaced with JsonParser.parseString(), but this change should be consistent throughout the file. The same pattern should be applied to line 702 where JsonParser.parseString() is used in the new code.

Copilot uses AI. Check for mistakes.
@shwstppr
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@shwstppr
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@shwstppr a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-14326)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 54256 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11619-t14326-kvm-ol8.zip
Smoke tests completed. 146 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_03_deploy_and_scale_kubernetes_cluster Failure 1.16 test_kubernetes_clusters.py
test_04_autoscale_kubernetes_cluster Failure 26.82 test_kubernetes_clusters.py

Copy link
Contributor

@kiranchavala kiranchavala left a comment

Choose a reason for hiding this comment

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

@shwstppr unable to deploy vm on proxmox host, during the vm deployment provided only vm_name in external details

Getting the following exception


2025-09-22 08:34:49,095 WARN  [o.a.c.h.e.p.ExternalPathPayloadProvisioner] (DirectAgent-10:[ctx-c16a7629]) (logid:73cf7b1d) Failed to create the instance daf26bd7-2b9e-4480-acd6-ce2edce8f430 on external system: External API execution failed with exit code 1
2025-09-22 08:34:49,095 DEBUG [o.a.c.h.e.p.ExternalPathPayloadProvisioner] (DirectAgent-10:[ctx-c16a7629]) (logid:73cf7b1d) Deploying VM daf26bd7-2b9e-4480-acd6-ce2edce8f430 on the external system failed: Exit code: 1, Output: {"error":"Missing required fields: vmid"}

The issue was not present before

@shwstppr
Copy link
Contributor Author

@kiranchavala are you able to deploy VMs when not using PR changes?
I don't think I changed things directly around deployment or parameter passing so this could either be an environmental issue or side effects of changes

@github-actions
Copy link

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

@shwstppr
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@shwstppr shwstppr marked this pull request as ready for review November 10, 2025 10:56
@shwstppr shwstppr requested a review from abh1sar November 10, 2025 11:01
@shwstppr shwstppr changed the base branch from main to 4.22 November 10, 2025 11:07
Add `statuses` action in extensions to report VM power states

This PR introduces support for retrieving the power state of all VMs on a host directly from an extension using the new `statuses` action.
When available, this provides a single aggregated response, reducing the need for multiple calls.

If the extension does not implement `statuses`, the server will gracefully fall back to querying individual VMs using the existing `status` action.

This helps with updating the host in CloudStack after out-of-band migrations for the VM.

Signed-off-by: Abhishek Kumar <[email protected]>
@shwstppr shwstppr force-pushed the improve-ext-powerreport branch from 2129c80 to bc826b8 Compare November 10, 2025 11:33
@apache apache deleted a comment from blueorangutan Nov 10, 2025
@shwstppr
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@abh1sar
Copy link
Collaborator

abh1sar commented Nov 11, 2025

I have started looking. Will finish the review by tomorrow.

Copy link
Collaborator

@abh1sar abh1sar left a comment

Choose a reason for hiding this comment

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

code LGTM with 2 minor comments.

}'
}
get_console() {
check_required_fields node vmid
Copy link
Collaborator

Choose a reason for hiding this comment

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

indentation is changed from 4 to 3 spaces.

doReturn(new Pair<>(false, "Error")).when(provisioner)
.getInstanceStatusesOnExternalSystem(anyString(), anyString(), anyString(), anyMap(), anyInt());

Map<String, HostVmStateReportEntry> result = provisioner.getVmPowerStates(host, accessDetails, "test-extension", "test-path");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any assertion here?

@abh1sar abh1sar removed their assignment Nov 13, 2025
Signed-off-by: Abhishek Kumar <[email protected]>
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.

5 participants