Skip to content

Support list/query async jobs by resource#12983

Open
sureshanaparti wants to merge 5 commits intoapache:4.22from
shapeblue:async-jobs-resource-filtering
Open

Support list/query async jobs by resource#12983
sureshanaparti wants to merge 5 commits intoapache:4.22from
shapeblue:async-jobs-resource-filtering

Conversation

@sureshanaparti
Copy link
Copy Markdown
Contributor

@sureshanaparti sureshanaparti commented Apr 8, 2026

Description

This PR enhances listAsyncJobs and queryAsyncJobResult API to retrieve asynchronous job for the resources (VM/Volume)

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

How Has This Been Tested?

Tested the list asyncjobs and query asyncjobresult calls with resourceid and resourcetype params (after performing stop/start vm and migrate volume).

(localcloud) 🐱 > list asyncjobs resourceid=ec8cf417-a7d9-4ff4-bfab-4e5a68dca499 resourcetype=virtualmachine
{
  "asyncjobs": [
    {
      "account": "admin",
      "accountid": "30c6c5dd-33c9-11f1-9da0-1e00d7000376",
      "cmd": "org.apache.cloudstack.api.command.admin.vm.StopVMCmdByAdmin",
      "created": "2026-04-10T14:27:14+0000",
      "domainid": "e1beab01-33c8-11f1-9da0-1e00d7000376",
      "domainpath": "ROOT",
      "jobid": "fa27ff8b-6479-43e4-93ce-fe288df8feb1",
      "jobinstanceid": "ec8cf417-a7d9-4ff4-bfab-4e5a68dca499",
      "jobinstancetype": "VirtualMachine",
      "jobprocstatus": 0,
      "jobresultcode": 0,
      "jobstatus": 0,
      "managementserverid": "670e746e-91c1-4847-889d-51e582812bce",
      "managementservername": "ref-trl-11539-k-mol8-suresh-anaparti-mgmt1.sofia.shapeblue.com",
      "userid": "30c7a56f-33c9-11f1-9da0-1e00d7000376"
    },
    {
      "account": "admin",
      "accountid": "30c6c5dd-33c9-11f1-9da0-1e00d7000376",
      "cmd": "org.apache.cloudstack.api.command.admin.vm.StartVMCmdByAdmin",
      "created": "2026-04-10T14:27:14+0000",
      "domainid": "e1beab01-33c8-11f1-9da0-1e00d7000376",
      "domainpath": "ROOT",
      "jobid": "f2f744cc-2a39-46e1-a6ff-446f5950b4d9",
      "jobinstanceid": "ec8cf417-a7d9-4ff4-bfab-4e5a68dca499",
      "jobinstancetype": "VirtualMachine",
      "jobprocstatus": 0,
      "jobresultcode": 0,
      "jobstatus": 0,
      "managementserverid": "670e746e-91c1-4847-889d-51e582812bce",
      "managementservername": "ref-trl-11539-k-mol8-suresh-anaparti-mgmt1.sofia.shapeblue.com",
      "userid": "30c7a56f-33c9-11f1-9da0-1e00d7000376"
    }
  ],
  "count": 2
}

(localcloud) 🐱 > list asyncjobs resourceid=688fc6a9-12a7-4cad-a15a-a574e6cc60af resourcetype=volume
{
  "asyncjobs": [
    {
      "account": "admin",
      "accountid": "30c6c5dd-33c9-11f1-9da0-1e00d7000376",
      "cmd": "org.apache.cloudstack.api.command.admin.volume.MigrateVolumeCmdByAdmin",
      "created": "2026-04-10T14:27:14+0000",
      "domainid": "e1beab01-33c8-11f1-9da0-1e00d7000376",
      "domainpath": "ROOT",
      "jobid": "d3362e06-5552-48ea-a8dd-ce29d0d406b4",
      "jobinstanceid": "688fc6a9-12a7-4cad-a15a-a574e6cc60af",
      "jobinstancetype": "Volume",
      "jobprocstatus": 0,
      "jobresultcode": 0,
      "jobstatus": 0,
      "managementserverid": "670e746e-91c1-4847-889d-51e582812bce",
      "managementservername": "ref-trl-11539-k-mol8-suresh-anaparti-mgmt1.sofia.shapeblue.com",
      "userid": "30c7a56f-33c9-11f1-9da0-1e00d7000376"
    }
  ],
  "count": 1
}
(localcloud) 🐱 > list asyncjobs resourceid=e095bfa7-37c6-477b-8fca-94680a02629a resourcetype=volume
{
  "asyncjobs": [
    {
      "account": "admin",
      "accountid": "30c6c5dd-33c9-11f1-9da0-1e00d7000376",
      "cmd": "org.apache.cloudstack.api.command.admin.volume.MigrateVolumeCmdByAdmin",
      "created": "2026-04-10T14:27:14+0000",
      "domainid": "e1beab01-33c8-11f1-9da0-1e00d7000376",
      "domainpath": "ROOT",
      "jobid": "12233c63-1c72-4a6f-b8d6-d2cee8aa9b44",
      "jobinstanceid": "e095bfa7-37c6-477b-8fca-94680a02629a",
      "jobinstancetype": "Volume",
      "jobprocstatus": 0,
      "jobresultcode": 0,
      "jobstatus": 0,
      "managementserverid": "670e746e-91c1-4847-889d-51e582812bce",
      "managementservername": "ref-trl-11539-k-mol8-suresh-anaparti-mgmt1.sofia.shapeblue.com",
      "userid": "30c7a56f-33c9-11f1-9da0-1e00d7000376"
    }
  ],
  "count": 1
}

(localcloud) 🐱 > query asyncjobresult resourceid=ec8cf417-a7d9-4ff4-bfab-4e5a68dca499 resourcetype=virtualmachine
{
  "account": "admin",
  "accountid": "30c6c5dd-33c9-11f1-9da0-1e00d7000376",
  "cmd": "org.apache.cloudstack.api.command.admin.vm.StartVMCmdByAdmin",
  "created": "2026-04-10T14:27:14+0000",
  "domainid": "e1beab01-33c8-11f1-9da0-1e00d7000376",
  "domainpath": "ROOT",
  "jobid": "f2f744cc-2a39-46e1-a6ff-446f5950b4d9",
  "jobinstanceid": "ec8cf417-a7d9-4ff4-bfab-4e5a68dca499",
  "jobinstancetype": "VirtualMachine",
  "jobprocstatus": 0,
  "jobresultcode": 0,
  "jobstatus": 0,
  "managementserverid": "670e746e-91c1-4847-889d-51e582812bce",
  "managementservername": "ref-trl-11539-k-mol8-suresh-anaparti-mgmt1.sofia.shapeblue.com",
  "userid": "30c7a56f-33c9-11f1-9da0-1e00d7000376"
}

(localcloud) 🐱 > query asyncjobresult resourceid=688fc6a9-12a7-4cad-a15a-a574e6cc60af resourcetype=volume
{
  "account": "admin",
  "accountid": "30c6c5dd-33c9-11f1-9da0-1e00d7000376",
  "cmd": "org.apache.cloudstack.api.command.admin.volume.MigrateVolumeCmdByAdmin",
  "created": "2026-04-10T14:27:14+0000",
  "domainid": "e1beab01-33c8-11f1-9da0-1e00d7000376",
  "domainpath": "ROOT",
  "jobid": "d3362e06-5552-48ea-a8dd-ce29d0d406b4",
  "jobinstanceid": "688fc6a9-12a7-4cad-a15a-a574e6cc60af",
  "jobinstancetype": "Volume",
  "jobprocstatus": 0,
  "jobresultcode": 0,
  "jobstatus": 0,
  "managementserverid": "670e746e-91c1-4847-889d-51e582812bce",
  "managementservername": "ref-trl-11539-k-mol8-suresh-anaparti-mgmt1.sofia.shapeblue.com",
  "userid": "30c7a56f-33c9-11f1-9da0-1e00d7000376"
}

(localcloud) 🐱 > query asyncjobresult resourceid=e095bfa7-37c6-477b-8fca-94680a02629a resourcetype=volume
{
  "account": "admin",
  "accountid": "30c6c5dd-33c9-11f1-9da0-1e00d7000376",
  "cmd": "org.apache.cloudstack.api.command.admin.volume.MigrateVolumeCmdByAdmin",
  "created": "2026-04-10T14:27:14+0000",
  "domainid": "e1beab01-33c8-11f1-9da0-1e00d7000376",
  "domainpath": "ROOT",
  "jobid": "12233c63-1c72-4a6f-b8d6-d2cee8aa9b44",
  "jobinstanceid": "e095bfa7-37c6-477b-8fca-94680a02629a",
  "jobinstancetype": "Volume",
  "jobprocstatus": 0,
  "jobresultcode": 0,
  "jobstatus": 0,
  "managementserverid": "670e746e-91c1-4847-889d-51e582812bce",
  "managementservername": "ref-trl-11539-k-mol8-suresh-anaparti-mgmt1.sofia.shapeblue.com",
  "userid": "30c7a56f-33c9-11f1-9da0-1e00d7000376"
}
(localcloud) 🐱 > list asyncjobs resourcetype=virtualmachine
🙈 Error: (HTTP 431, error code 4350) Invalid resource id for the resource type VirtualMachine
(localcloud) 🐱 > 
(localcloud) 🐱 > list asyncjobs resourceid=ec8cf417-a7d9-4ff4-bfab-4e5a68dca499
🙈 Error: (HTTP 431, error code 4350) Resource type must be specified for the resource id
(localcloud) 🐱 >
(localcloud) 🐱 > list asyncjobs resourceid=ec8cf417-a7d9-4ff4-bfab-4e5a68dca499 resourcetype=virtual
🙈 Error: (HTTP 431, error code 4350) Invalid resourcetype
(localcloud) 🐱 > list asyncjobs resourceid=ec8cf417-a7d9-4ff4-bfab resourcetype=virtualmachine
🙈 Error: (HTTP 431, error code 9999) Unable to execute API command listasyncjobs due to invalid value. Invalid value provided for API arg: resourceid

(localcloud) 🐱 > query asyncjobresult
🙈 Error: (HTTP 431, error code 4350) Expected parameter job id or parameters resource type and resource id
(localcloud) 🐱 > 
(localcloud) 🐱 > query asyncjobresult resourceid=ec8cf417-a7d9-4ff4-bfab-4e5a68dca499
🙈 Error: (HTTP 431, error code 4350) Both resourceid and resourcetype required
(localcloud) 🐱 > 
(localcloud) 🐱 > query asyncjobresult resourcetype=virtualmachine
🙈 Error: (HTTP 431, error code 4350) Both resourceid and resourcetype required
(localcloud) 🐱 > 
(localcloud) 🐱 > query asyncjobresult resourceid=ec8cf417 resourcetype=virtualmachine
🙈 Error: (HTTP 431, error code 9999) Unable to execute API command queryasyncjobresult due to invalid value. Invalid value provided for API arg: resourceid
(localcloud) 🐱 >

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

@sureshanaparti
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@sureshanaparti 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
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 32.14286% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.61%. Comparing base (03de62b) to head (7e43a3e).
⚠️ Report is 17 commits behind head on 4.22.

Files with missing lines Patch % Lines
...cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java 0.00% 21 Missing ⚠️
...in/java/com/cloud/api/query/ResourceIdSupport.java 48.64% 18 Missing and 1 partial ⚠️
...src/main/java/com/cloud/api/ApiResponseHelper.java 45.45% 12 Missing ⚠️
...ain/java/com/cloud/api/query/QueryManagerImpl.java 33.33% 10 Missing and 2 partials ⚠️
...udstack/api/command/user/job/ListAsyncJobsCmd.java 0.00% 6 Missing ⚠️
...k/api/command/user/job/QueryAsyncJobResultCmd.java 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               4.22   #12983    +/-   ##
==========================================
  Coverage     17.60%   17.61%            
- Complexity    15674    15691    +17     
==========================================
  Files          5918     5919     +1     
  Lines        531727   531986   +259     
  Branches      65016    65058    +42     
==========================================
+ Hits          93595    93692    +97     
- Misses       427570   427729   +159     
- Partials      10562    10565     +3     
Flag Coverage Δ
uitests 3.70% <ø> (-0.01%) ⬇️
unittests 18.68% <32.14%> (+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.

Copy link
Copy Markdown
Contributor

@nvazquez nvazquez left a comment

Choose a reason for hiding this comment

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

LGTM

@blueorangutan
Copy link
Copy Markdown

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

@nvazquez
Copy link
Copy Markdown
Contributor

nvazquez commented Apr 8, 2026

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

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

Test Result Time (s) Test File

Copy link
Copy Markdown
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm

@sureshanaparti
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@sureshanaparti 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
Copy Markdown

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

@DaanHoogland
Copy link
Copy Markdown
Contributor

@nvazquez, did you test this?

@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-15851)

@sureshanaparti
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@sureshanaparti 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
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

5 participants