Skip to content

listHosts: add 'core' details - #13444

Merged
sureshanaparti merged 3 commits into
apache:4.22from
shapeblue:422-add-core-details-listhosts
Jul 3, 2026
Merged

listHosts: add 'core' details#13444
sureshanaparti merged 3 commits into
apache:4.22from
shapeblue:422-add-core-details-listhosts

Conversation

@nvazquez

@nvazqueznvazquez commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds a detail core for the listHosts API, which avoids making extra DB queries per host listed.

This will drastically reduce the time it takes to listHosts and allows us to get a list of hosts & their state, which can take lot of time for the API to complete if the core detail is not passed on large environments.

This is strictly opt-in with listHosts details=core and the default bahaviour is unchanged.

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?

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

@nvazquez

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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

codecovBot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 3.69%. Comparing base (8e933b7) to head (2a4995c).
⚠️ Report is 36 commits behind head on 4.22.

❗ There is a different number of reports uploaded between BASE (8e933b7) and HEAD (2a4995c). Click for more details.

HEAD has 1 upload less than BASE
FlagBASE (8e933b7)HEAD (2a4995c)
unittests10
Additional details and impacted files
@@ Coverage Diff @@## 4.22 #13444 +/- ##
=============================================
- Coverage 17.67% 3.69% -13.98% 
=============================================
Files 5922 448 -5474 Lines 533167 38107 -495060 Branches 65210 7061 -58149 =============================================
- Hits 94246 1409 -92837 + Misses 428276 36511 -391765 + Partials 10645 187 -10458 
FlagCoverage Δ
uitests3.69% <ø> (ø)
unittests?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@blueorangutan

Copy link
Copy Markdown

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

@weizhouapache

Copy link
Copy Markdown
Member

@nvazquez
have you considered the backward compatibility ?

@sureshanapartisureshanaparti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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 opt-in details=core option for the listHosts API, intended to return a lightweight “core” host response and avoid per-host (N+1) lookups performed by the existing response builder.

Changes:

  • Added core to ApiConstants.HostDetails so listHosts can accept details=core.
  • Implemented a new “core” host response path in HostJoinDaoImpl.newHostResponse(...) via setNewCoreHostResponse(...).

Reviewed changes

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

FileDescription
server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.javaAdds a new lightweight host response builder and routes details=core requests to it.
api/src/main/java/org/apache/cloudstack/api/ApiConstants.javaAdds core to the HostDetails enum (allowed values for details).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadserver/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java Outdated
Comment threadserver/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java Outdated
Comment threadserver/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java Outdated
@RosiKyuRosiKyu self-assigned this Jun 23, 2026
@GaOrtiga

GaOrtiga commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

@nvazquez in the description you mentioned avoiding requests when getting details like cpu usage, but I don't see this parameter in specific being added to the response, am I missing something?

Comment threadapi/src/main/java/org/apache/cloudstack/api/ApiConstants.java Outdated
@GaOrtiga

Copy link
Copy Markdown
Collaborator

Also, the copilot left a review regarding the MS ID that I kind of agree. This API is admin only, so shouldn't be a big deal returning the internal ID, however, this same api returns MS UUID when other filters are passed, having this one be different may cause confusion

@nvazquez
nvazquez marked this pull request as draft June 23, 2026 15:57
@nvazquez

Copy link
Copy Markdown
ContributorAuthor

Thanks @RosiKyu@GaOrtiga@weizhouapache - I have refactored the code according to your review comments and Copilot comments. The only pending item is the msid return value, I'm keeping this PR in draft while this is not addressed and will put back to review state once its sorted out

@nvazquez

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

@nvazquez
nvazquez marked this pull request as ready for review June 26, 2026 18:50
@nvazquez

Copy link
Copy Markdown
ContributorAuthor

@GaOrtiga@RosiKyu please find the PR ready for review again. I have introduced a new response field msid which is only retrieved when details=core is passed to the listHosts API, to avoid confusions with the field managementserverid.

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

@nvazquez

Copy link
Copy Markdown
ContributorAuthor

@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-16445)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 49425 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13444-t16445-kvm-ol8.zip
Smoke tests completed. 148 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
ContextSuite context=TestAccounts>:setupError0.00test_accounts.py
ContextSuite context=TestAddVmToSubDomain>:setupError0.00test_accounts.py
test_DeleteDomainError12.13test_accounts.py
test_forceDeleteDomainFailure12.01test_accounts.py
ContextSuite context=TestRemoveUserFromAccount>:setupError12.65test_accounts.py

@RosiKyuRosiKyu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Tested on 4.22.2.0

  • listHosts details=core returns the lightweight host set as intended; default listing unchanged.
  • Management server returned as numeric msid under core - confirmed intentional (avoids a per-host DB lookup).
  • listHostsMetrics details=core returns HTTP 530
  • External hypervisor hosts don't return extensionid/extensionname under core- accepted as won't-fix (fetching it would add a lookup and reduce the performance core exists for).

Follow-up: doc/API-docs note for the core detail.

@sureshanaparti
sureshanaparti merged commit 135922f into apache:4.22Jul 3, 2026
24 of 26 checks passed
@sureshanaparti
sureshanaparti deleted the 422-add-core-details-listhosts branch July 3, 2026 12:18
Sign up for freeto 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.

7 participants

@nvazquez@blueorangutan@weizhouapache@GaOrtiga@sureshanaparti@RosiKyu