Repository navigation
Async jobs improvements - #14270
Async jobs improvements#14270sureshanaparti wants to merge 78 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Cancellation races can terminate refused jobs or finalize jobs while backend work continues, and several API/UI fields are ineffective or omitted.
Review effort: Balanced
Findings: 3
Open (6)
Enable cancellability on concrete command annotations · New Mark cancellation only after cancelRunning succeeds · New Do not finalize cancelled jobs while remote work continues · New Prevent completed future leak during submit race · New Map execution time into listUsageJobs responses · New Allow Activity access with Jobs or Alerts permissions · New
What changed in this PR
Adds async-job filtering, cancellation, event linkage, usage-job visibility, and an Activity-focused UI across CloudStack.
Changes:
- Adds cross-layer async-job cancellation for KVM, VMware, and XenServer.
- Extends job/event/usage APIs with filtering, status, duration, and linkage data.
- Adds Activity, resource job tabs, usage-job views, and automated tests.
| File | Description |
|---|---|
vmware-base/.../VmwareTaskRegistryTest.java |
Tests VMware task tracking and cancellation. |
vmware-base/.../VmwareTaskRegistry.java |
Tracks cancellable VMware tasks. |
vmware-base/.../VmwareClient.java |
Registers, cancels, and polls VMware tasks. |
utils/.../SerialVersionUID.java |
Adds cancellation exception UID. |
utils/.../CSExceptionErrorCode.java |
Registers cancellation error code. |
ui/.../UsageJobsTab.vue |
Adds usage-job table. |
ui/.../AsyncJobsTab.vue |
Adds filtering, pagination, and cancellation UI. |
ui/.../InstanceTab.vue |
Adds instance Jobs tab. |
ui/.../JobsView.vue |
Adds global Jobs view. |
ui/.../storage.js |
Adds volume Jobs tab. |
ui/.../managementServers.js |
Adds management and usage job tabs. |
ui/.../infra.js |
Moves alerts out of Infrastructure. |
ui/.../event.js |
Removes standalone Events section. |
ui/.../activity.js |
Adds Activity section. |
ui/.../router.js |
Registers Activity routing. |
ui/public/locales/en.json |
Adds job-related labels. |
test/.../test_async_jobs.py |
Adds async-job smoke coverage. |
server/.../UsageServiceImpl.java |
Implements usage-job listing. |
server/.../ManagementServerImpl.java |
Registers usage-job API. |
server/.../EventJoinDaoImpl.java |
Exposes event job IDs. |
server/.../ActionEventUtils.java |
Links events to current jobs. |
server/.../ConfigurationManagerImpl.java |
Validates cancellation interval. |
server/.../EventJoinVO.java |
Maps event job columns. |
server/.../AsyncJobJoinVO.java |
Maps completion server and related job. |
server/.../QueryManagerImpl.java |
Adds job/event filtering. |
server/.../AsyncJobJoinDaoImpl.java |
Reports executing/completing server. |
server/.../ApiResponseHelper.java |
Creates cancellation responses. |
server/.../ApiAsyncJobDispatcher.java |
Preserves terminal cancellation status. |
plugins/.../XenServerTaskRegistryTest.java |
Tests XenServer cancellation registry. |
plugins/.../CitrixResourceBaseTest.java |
Tests unknown XenServer requests. |
plugins/.../XenServerTaskRegistry.java |
Tracks XenAPI tasks. |
plugins/.../CitrixResourceBase.java |
Integrates XenServer cancellation. |
plugins/.../VmwareResourceTest.java |
Tests unknown VMware requests. |
plugins/.../VmwareResource.java |
Integrates VMware cancellation. |
plugins/.../LibvirtCancelCommandWrapperTest.java |
Tests KVM cancel wrapper. |
plugins/.../KvmCancellableRequestsTest.java |
Tests KVM request tracking. |
plugins/.../LibvirtCancelCommandWrapper.java |
Handles KVM cancel commands. |
plugins/.../LibvirtComputingResource.java |
Integrates KVM cancellation hooks. |
plugins/.../KvmCancellableRequests.java |
Tracks KVM cancellation hooks. |
framework/jobs/.../AsyncJobMonitor.java |
Tracks active job IDs. |
framework/jobs/.../AsyncJobManagerImpl.java |
Implements job cancellation lifecycle. |
framework/jobs/.../AsyncJobDaoImpl.java |
Queries related/cancelled jobs. |
framework/jobs/.../AsyncJobDao.java |
Extends job DAO contract. |
framework/jobs/.../AsyncJobManager.java |
Extends cancellation lifecycle API. |
framework/jobs/.../AsyncJobExecutionContext.java |
Handles missing join records. |
engine/schema/.../cloud.event_view.sql |
Adds event/job linkage. |
engine/schema/.../cloud.async_job_view.sql |
Adds related and completion fields. |
engine/schema/.../schema-42300to2400.sql |
Migrates event job linkage. |
engine/schema/.../EventVO.java |
Persists event job IDs. |
engine/orchestration/.../DirectAgentAttacheTest.java |
Tests direct-agent cancellation. |
engine/orchestration/.../ConnectedAgentAttacheTest.java |
Tests connected-agent cancellation. |
engine/orchestration/.../DirectAgentAttache.java |
Tracks and cancels direct tasks. |
engine/orchestration/.../ConnectedAgentAttache.java |
Sends agent cancel commands. |
engine/orchestration/.../AgentManagerImpl.java |
Coordinates job/agent cancellation. |
engine/orchestration/.../AgentAttache.java |
Adds cancellation-aware request handling. |
engine/components-api/.../AgentManager.java |
Exposes cancellation services. |
core/.../CancelCommandTest.java |
Tests cancellation probe mode. |
core/.../ServerResource.java |
Adds resource cancellation hooks. |
core/.../RequestExecutionContext.java |
Carries request sequence context. |
core/.../Request.java |
Tracks request cancellation. |
core/.../CancelCommand.java |
Adds probe-only cancellation mode. |
api/.../UsageService.java |
Exposes usage-job listing. |
api/.../JobInfo.java |
Adds explicit status values. |
api/.../JobCancellationHandler.java |
Defines cancellation handler contract. |
api/.../AsyncJobService.java |
Defines cancellation service/configuration. |
api/.../ResponseGenerator.java |
Adds cancellation response contract. |
api/.../UsageJobResponse.java |
Defines usage-job response. |
api/.../MigrateVolumeCmd.java |
Marks migration cancellable. |
api/.../DetachVolumeCmd.java |
Marks detach cancellable. |
api/.../DestroyVolumeCmd.java |
Marks volume destruction cancellable. |
api/.../CreateVolumeCmd.java |
Marks volume creation cancellable. |
api/.../AttachVolumeCmd.java |
Marks attach cancellable. |
api/.../RevertToVMSnapshotCmd.java |
Marks revert cancellable. |
api/.../DeleteVMSnapshotCmd.java |
Marks deletion cancellable. |
api/.../CreateVMSnapshotCmd.java |
Marks creation cancellable. |
api/.../StopVMCmd.java |
Marks stop cancellable. |
api/.../StartVMCmd.java |
Marks start cancellable. |
api/.../RebootVMCmd.java |
Marks reboot cancellable. |
api/.../DestroyVMCmd.java |
Marks VM destruction cancellable. |
api/.../BaseDeployVMCmd.java |
Declares deploy cancellation intent. |
api/.../RevertSnapshotCmd.java |
Marks snapshot revert cancellable. |
api/.../DeleteSnapshotCmd.java |
Marks snapshot deletion cancellable. |
api/.../CreateSnapshotCmd.java |
Marks snapshot creation cancellable. |
api/.../ListAsyncJobsCmd.java |
Adds status/date/duration filters. |
api/.../CancelAsyncJobCmd.java |
Adds cancellation API. |
api/.../ListEventsCmd.java |
Adds job-based event filtering. |
api/.../MigrateVolumeCmdByAdmin.java |
Marks admin migration cancellable. |
api/.../DetachVolumeCmdByAdmin.java |
Marks admin detach cancellable. |
api/.../DestroyVolumeCmdByAdmin.java |
Marks admin destruction cancellable. |
api/.../CreateVolumeCmdByAdmin.java |
Marks admin creation cancellable. |
api/.../AttachVolumeCmdByAdmin.java |
Marks admin attach cancellable. |
api/.../RevertToVMSnapshotCmdByAdmin.java |
Marks admin revert cancellable. |
api/.../StopVMCmdByAdmin.java |
Marks admin stop cancellable. |
api/.../StartVMCmdByAdmin.java |
Marks admin start cancellable. |
api/.../RebootVMCmdByAdmin.java |
Marks admin reboot cancellable. |
api/.../MigrateVMCmd.java |
Marks VM migration cancellable. |
api/.../MigrateVirtualMachineWithVolumeCmd.java |
Marks combined migration cancellable. |
api/.../DestroyVMCmdByAdmin.java |
Marks admin VM destruction cancellable. |
api/.../ListUsageJobsCmd.java |
Adds usage-job API. |
api/.../ApiConstants.java |
Adds usage-server constant. |
api/.../ApiCommandResourceType.java |
Adds Job resource type. |
api/.../APICommand.java |
Adds cancellable command metadata. |
api/.../VirtualMachine.java |
Adds Starting-to-Stopping transition. |
api/.../OperationCancelledException.java |
Adds cancellation exception. |
api/.../EventTypes.java |
Adds job-cancel event type. |
api/.../Answer.java |
Adds cancelled-answer state. |
agent/.../Agent.java |
Propagates request sequences. |
.github/workflows/ci.yml |
Runs new smoke tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #14270 +/- ##
============================================
+ Coverage 3.86% 21.07% +17.20%
- Complexity 0 21483 +21483
============================================
Files 494 6073 +5579
Lines 42888 551887 +508999
Branches 8141 79322 +71181
============================================
+ Hits 1657 116302 +114645
- Misses 40999 421949 +380950
- Partials 232 13636 +13404
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@blueorangutan package |
|
@sureshanaparti 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. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19353 |
|
@blueorangutan test keepEnv |
|
@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
@blueorangutan test matrix |
|
@sureshanaparti a [SL] Trillian-Jenkins matrix job (ol8 mgmt + kvm-ol8, ubuntu22 mgmt + kvm-ubuntu22, ol8 mgmt + vmware-70u3, ol9 mgmt + xcpng82) has been kicked to run smoke tests |
|
[SF] Trillian Build Failed (tid-17049) |
|
[SF] Trillian test result (tid-17046)
|
|
[SF] Trillian test result (tid-17048)
|
…t for cancelled work job readable by its parent
…ancel to direct agent host (VMware/XenServer) is answered by its owner
9686322 to
7a4d1b5
Compare
|
@blueorangutan package |
|
@sureshanaparti 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. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 20231 |
kiranchavala
left a comment
There was a problem hiding this comment.
LGTM , tested manually the api call with the following 17 api calls
cmk cancel asyncjob jobid=,
Compare with the 17 cancellable APIs
start, stop, reboot, destroy, migrate VM, migrate VM with volume,
create, attach, detach, destroy and migrate volume,
create, delete and revert snapshot,
create, delete and revert VM snapshot
Job status codes:
0: pending
1: succeeded
2: failed
3: cancelled
Cancel: cmk cancel asyncjob jobid=, run as root admin.
Cancel at +N s: submit the API with asyncblock false, wait N seconds, then cancel.
KVM: virsh list --all and the primary pool directory.
VMware: vCenter inventory, Recent Tasks and the datastore browser.
Xen: xe vm-list, xe vdi-list and the SR.
Secondary storage: the snapshot or template directory.
Refused: the cancel API returns Cannot cancel job-N … . cancelrequested stays false, and the job finishes normally with status 1.
Common preconditions:
An admin and a normal user cmk profile.
Two hosts per cluster and two primary pools.
A VM with a 20 GB+ ROOT disk running a memory load such as stress-ng --vm 1 --vm-bytes 75%, so migrations are slow.
A 20 GB+ DATA disk.
Two management servers.
performed the following test cases
| Test Case Execution | Result |
|---|---|
| API visible to root admin only | Pass |
| User can't cancel | Pass |
| api support cancellable | Pass |
| Cancel a Finished job | Pass |
| cancel a Unknown job | Pass |
| Running non-cancellable API command | Pass |
| Cancel a stop vm | Pass |
| Cancel a reboot vm | Pass |
| Cancel a volume snapshot during the hypervisor snapshot | Pass |
| Cancel a create volume from snapshot | Pass |
| Accepted cancel job ends | Pass |
| canceled async job leaves no stale entries on the hypervisor and db | Pass |
| Queued work job cancelled | Pass |
| Forwarded cancel accepted | Pass |
| Forwarded cancel refused | Pass |
| Owner MS down | Pass |
| Events for an accepted cancel | Pass |
| Check usage records fore Cancelled volume migration | Pass |
| Check usage records for Cancelled migrate with volume | Pass |
| Check usage records for Cancelled create volume from snapshot | Pass |
| Check usage records for Cancelled snapshot | Pass |
| check listAsync jobs api | Pass |
| UI : Cancel button shown for cancellable jobs | Pass |
| UI : Cancel hidden/disabled | Pass |
| Test cancelling Live vm migration, memory copy | Pass |
| Test cancelling Migration with volumes, disk copy | Pass |
| cancel during Delete and revert snapshot | Pass |
| Cancel during Create disk-only VM snapshot | Pass |
| Cancel during Create memory VM snapshot | Pass |
| Cancel during Revert to VM snapshot | Pass |
| Cancel during Delete VM snapshot | Pass |
| Cancel during Destroy with expunge | Pass |


Description
This PR has the following async jobs related improvements.
More details here: https://cwiki.apache.org/confluence/spaces/CLOUDSTACK/pages/451979060/Async+Jobs+Improvements
Dor PR: apache/cloudstack-documentation#693
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?