Skip to content

listHosts: add 'core' details#13444

Open
nvazquez wants to merge 1 commit into
apache:4.22from
shapeblue:422-add-core-details-listhosts
Open

listHosts: add 'core' details#13444
nvazquez wants to merge 1 commit into
apache:4.22from
shapeblue:422-add-core-details-listhosts

Conversation

@nvazquez

Copy link
Copy Markdown
Contributor

Description

This PR adds a detail core for the listHosts API, which makes it so we don't make N+1 queries when getting details (cpu usage, clusterid, etc.).

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

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
Contributor Author

@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

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.67%. Comparing base (8e933b7) to head (caf5fb8).
⚠️ Report is 3 commits behind head on 4.22.

Files with missing lines Patch % Lines
.../java/com/cloud/api/query/dao/HostJoinDaoImpl.java 0.00% 38 Missing ⚠️
...n/java/org/apache/cloudstack/api/ApiConstants.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #13444      +/-   ##
============================================
- Coverage     17.67%   17.67%   -0.01%     
+ Complexity    15792    15790       -2     
============================================
  Files          5922     5922              
  Lines        533167   533204      +37     
  Branches      65210    65215       +5     
============================================
- Hits          94246    94220      -26     
- Misses       428276   428337      +61     
- Partials      10645    10647       +2     
Flag Coverage Δ
uitests 3.69% <ø> (ø)
unittests 18.74% <0.00%> (-0.01%) ⬇️

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 ?

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

Copilot AI 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.

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

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

Comment on lines +136 to +140
hostResponse.setZoneId(host.getZoneUuid());
hostResponse.setZoneName(host.getZoneName());
hostResponse.setPodId(host.getPodUuid());
hostResponse.setPodName(host.getPodName());
if (host.getClusterId() > 0) {
Comment on lines +157 to +160
// msid is returned as-is; callers resolve it to avoid a per-host lookup
if (host.getManagementServerId() != null) {
hostResponse.setManagementServerId(host.getManagementServerId().toString());
}
Comment on lines +382 to +386
if (details.contains(HostDetails.core)) {
setNewCoreHostResponse(host, hostResponse);
} else {
setNewHostResponseBase(host, details, hostResponse);
}
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