Skip to content

Improve Quota Statement#10506

Open
julien-vaz wants to merge 10 commits intoapache:mainfrom
scclouds:improve-quota-statement
Open

Improve Quota Statement#10506
julien-vaz wants to merge 10 commits intoapache:mainfrom
scclouds:improve-quota-statement

Conversation

@julien-vaz
Copy link
Copy Markdown
Contributor

Description

In the current version, the quotaStatement API is returning the internal ID for account and domain, which is not useful for users, since all APIs use/return the UUID. Also, when the usage_type parameter is informed, the API shows dummy records.

To address those problems:

  • the API was modified so it returns the resources' UUID;
  • the dummy records bug was fixed;
  • a new parameter showresources was added to display more information to the user about each usage type;
  • a new quotaStatementDetails API was created to list more details about each usage type;

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

How Has This Been Tested?

On CloudMonkey the quotaStatement API was called and:

  • the resources' UUID was returned instead of the internal ID;
  • when specified a usage_type no dummy records were showed;
  • the showresources parameter is properly working;

The quotaStatementDetails API was called successfully as well.

@julien-vaz
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@julien-vaz 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 ✖️ debian ✖️ suse15. SL-JID 12669

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 5, 2025

Codecov Report

❌ Patch coverage is 23.44498% with 320 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.01%. Comparing base (c361409) to head (fdeb202).

Files with missing lines Patch % Lines
...udstack/api/response/QuotaResponseBuilderImpl.java 32.05% 105 Missing and 1 partial ⚠️
...g/apache/cloudstack/quota/vo/QuotaUsageJoinVO.java 35.41% 62 Missing ⚠️
...he/cloudstack/quota/dao/QuotaUsageJoinDaoImpl.java 0.00% 37 Missing ⚠️
...apache/cloudstack/quota/vo/QuotaUsageDetailVO.java 0.00% 31 Missing ⚠️
...ache/cloudstack/quota/vo/QuotaUsageResourceVO.java 0.00% 27 Missing ⚠️
...ache/cloudstack/api/command/QuotaStatementCmd.java 15.78% 16 Missing ⚠️
.../cloudstack/quota/dao/QuotaUsageDetailDaoImpl.java 0.00% 15 Missing ⚠️
...i/response/QuotaStatementItemResourceResponse.java 0.00% 13 Missing ⚠️
...loudstack/api/response/QuotaStatementResponse.java 36.36% 7 Missing ⚠️
...c/main/java/com/cloud/utils/db/SearchCriteria.java 0.00% 4 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##               main   #10506    +/-   ##
==========================================
  Coverage     18.00%   18.01%            
- Complexity    16466    16481    +15     
==========================================
  Files          5977     5983     +6     
  Lines        537777   538072   +295     
  Branches      66037    66059    +22     
==========================================
+ Hits          96844    96912    +68     
- Misses       430011   430244   +233     
+ Partials      10922    10916     -6     
Flag Coverage Δ
uitests 3.52% <ø> (ø)
unittests 19.17% <23.44%> (+<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.

@winterhazel winterhazel self-requested a review March 6, 2025 13:06
@julien-vaz
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@julien-vaz 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 ✖️ debian ✖️ suse15. SL-JID 12689

@julien-vaz
Copy link
Copy Markdown
Contributor Author

I've just successfully builded the packages locally with -Dnoredist. Therefore, I'm requesting the package building again

@julien-vaz
Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@julien-vaz 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 ✔️ debian ✔️ suse15. SL-JID 12742

Copy link
Copy Markdown
Contributor

@lucas-a-martins lucas-a-martins left a comment

Choose a reason for hiding this comment

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

CLGTM

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

"accountName", "accountId", "domainId", "startDate", "endDate", "type", "showDetails")));
}
logger.debug("Creating quota statement from [{}] usage records for parameters [{}].", quotaUsages.size(),
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(cmd, "accountName", "accountId", "domainId", "startDate", "endDate", "type", "showDetails"));
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.

this seems the reuse of the same array of strings. Not for this PR but maybe we should allow String[] as parameter for ReflectionToStringBuilderUtils.reflectOnlySelectedFields. Or allow some kind of predefined default per class to be registered.

@bernardodemarco bernardodemarco self-requested a review June 4, 2025 17:38
@sureshanaparti
Copy link
Copy Markdown
Contributor

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

@harikrishna-patnala
Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@harikrishna-patnala 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 15133

@shwstppr shwstppr requested a review from Copilot September 23, 2025 05:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 enhances the quota statement API by addressing UUID usage, fixing dummy record bugs, and adding new functionality for resource detail display. The changes improve API consistency by returning UUIDs instead of internal IDs, resolve issues with dummy records when usage_type is specified, and introduce a new showresources parameter for detailed resource information.

  • Return UUIDs instead of internal IDs for accounts and domains in quota statements
  • Fix dummy record generation bug when usage_type parameter is provided
  • Add new showresources parameter and quotaStatementDetails API for enhanced resource visibility

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
QuotaServiceImpl.java Updates to use QuotaUsageJoinDao instead of QuotaUsageDao
QuotaResponseBuilderImpl.java Major refactoring to handle new UUID responses and resource details
QuotaStatementResponse.java Changes account/domain ID fields from Long to String for UUID support
QuotaStatementItemResponse.java Removes duplicate account/domain fields and adds resources field
QuotaStatementCmd.java Adds showresources parameter and simplifies date handling
Test files Updates to accommodate new DAO and method signature changes
New VO classes Addition of join and resource VOs to support enhanced functionality
New DAO classes Implementation of join and detail DAOs for improved data access

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Copy Markdown
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

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

Are schema changes missing here? Seeing some new VO classes but no corresponding SQL changes I can find

import org.apache.commons.lang3.builder.ToStringStyle;

@Entity
@Table(name = "quota_usage_detail")
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.

I feel table should be named differently as CLoudStack uses *_detail table for the details of the entity mostly in the similar format resource_id,name,value


import java.util.Date;

public class QuotaUsageResourceVO {
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.

Is this referring to any DB table?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No

@nvazquez
Copy link
Copy Markdown
Contributor

nvazquez commented Oct 1, 2025

Hi @julien-vaz is this PR ready for review? Looks like its missing SQL statements for new tables and views?

@github-actions
Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@winterhazel
Copy link
Copy Markdown
Member

Are schema changes missing here? Seeing some new VO classes but no corresponding SQL changes I can find

@shwstppr good catch, some schema changes are missing. I will add them.

@winterhazel
Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

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

@blueorangutan
Copy link
Copy Markdown

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

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.