Async jobs improvements - #14270
Async jobs improvements#14270sureshanaparti wants to merge 29 commits into
Conversation
- status (0 - Pending, 1 - Success, 2 - Failed, 3 - Cancelled), use comma-seperated list for multiple status - end date (jobs created on or before this date) - duration (in hours) up to now
- usage server: name / ip of the host where usage server is running - start date: usage jobs started on or after this date - end date: usage jobs started on or before this date - duration in hours up to now: usage jobs started or completed within that period up to now
Drop the OperationCancelledException catch and throws plumbing that the exception no longer needs now that it is unchecked: every one of those handlers only relabelled a cancellation as a timeout or an unavailable agent. Pass the agent request sequence to the resource thread (RequestExecutionContext) so a resource can track its backend work by the same sequence the agent layer cancels by.
A completed job keeps the server that completed it: async_job_view exposes job_complete_msid, the response falls back to it once executing_msid is cleared, and the managementserverid filter matches either column. Without this a completed job had no management server in the API and a server's finished jobs could not be listed.
cancelAsyncJob takes jobid, not id.
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 19.91% 19.95% +0.04%
- Complexity 20194 20324 +130
============================================
Files 6373 6385 +12
Lines 577230 578451 +1221
Branches 70696 70876 +180
============================================
+ Hits 114942 115446 +504
- Misses 449722 450383 +661
- Partials 12566 12622 +56
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)
|
|
[SF] Trillian test result (tid-17051)
|


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
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?