Skip to content

Conversation

@julien-vaz
Copy link
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
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@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

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 12669

@codecov
Copy link

codecov bot commented Mar 5, 2025

Codecov Report

❌ Patch coverage is 18.91192% with 313 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.58%. Comparing base (69cf299) to head (412a4bd).
⚠️ Report is 673 commits behind head on main.

Files with missing lines Patch % Lines
...udstack/api/response/QuotaResponseBuilderImpl.java 20.00% 103 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 ⚠️
.../cloudstack/quota/dao/QuotaUsageDetailDaoImpl.java 0.00% 15 Missing ⚠️
...i/response/QuotaStatementItemResourceResponse.java 0.00% 13 Missing ⚠️
...loudstack/api/response/QuotaStatementResponse.java 22.22% 7 Missing ⚠️
...ache/cloudstack/api/command/QuotaStatementCmd.java 40.00% 6 Missing ⚠️
...c/main/java/com/cloud/user/dao/AccountDaoImpl.java 0.00% 5 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #10506      +/-   ##
============================================
+ Coverage     16.15%   16.58%   +0.43%     
- Complexity    13273    13883     +610     
============================================
  Files          5666     5725      +59     
  Lines        498081   507484    +9403     
  Branches      60267    61596    +1329     
============================================
+ Hits          80475    84184    +3709     
- Misses       408593   413883    +5290     
- Partials       9013     9417     +404     
Flag Coverage Δ
uitests 3.96% <ø> (-0.04%) ⬇️
unittests 17.46% <18.91%> (+0.45%) ⬆️

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

@blueorangutan package

@blueorangutan
Copy link

@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

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 12689

@julien-vaz
Copy link
Contributor Author

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

@julien-vaz
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@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

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

Copy link
Collaborator

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

@blueorangutan package

@blueorangutan
Copy link

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

@julien-vaz
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@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

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

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

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

@JoaoJandre
Copy link
Contributor

@DaanHoogland could we try the tests again?

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File

@harikrishna-patnala
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@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

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

Comment on lines +935 to +936
} catch (ParseException e) {
e.printStackTrace();
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

Using e.printStackTrace() in test code is not recommended. Consider using a proper logging mechanism or re-throwing the exception as a RuntimeException to fail the test properly.

Copilot uses AI. Check for mistakes.
Comment on lines +948 to +949
} catch (ParseException e) {
e.printStackTrace();
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

Using e.printStackTrace() in test code is not recommended. Consider using a proper logging mechanism or re-throwing the exception as a RuntimeException to fail the test properly.

Copilot uses AI. Check for mistakes.
Comment on lines +961 to +962
} catch (ParseException e) {
e.printStackTrace();
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

Using e.printStackTrace() in test code is not recommended. Consider using a proper logging mechanism or re-throwing the exception as a RuntimeException to fail the test properly.

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +120
public void setStartDate(Date startDate) { this.startDate = startDate; }

public boolean isShowResources() { return showResources; }

public void setShowResources(boolean showResources) { this.showResources = showResources; }
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

Method declarations should be formatted consistently with proper spacing. Each method should be on separate lines with proper indentation for better readability.

Suggested change
public void setStartDate(Date startDate) { this.startDate = startDate; }
public boolean isShowResources() { return showResources; }
public void setShowResources(boolean showResources) { this.showResources = showResources; }
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public boolean isShowResources() {
return showResources;
}
public void setShowResources(boolean showResources) {
this.showResources = showResources;
}

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +120
public void setStartDate(Date startDate) { this.startDate = startDate; }

public boolean isShowResources() { return showResources; }

public void setShowResources(boolean showResources) { this.showResources = showResources; }
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

Method declarations should be formatted consistently with proper spacing. Each method should be on separate lines with proper indentation for better readability.

Suggested change
public void setStartDate(Date startDate) { this.startDate = startDate; }
public boolean isShowResources() { return showResources; }
public void setShowResources(boolean showResources) { this.showResources = showResources; }
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public boolean isShowResources() {
return showResources;
}
public void setShowResources(boolean showResources) {
this.showResources = showResources;
}

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +120
public void setStartDate(Date startDate) { this.startDate = startDate; }

public boolean isShowResources() { return showResources; }

public void setShowResources(boolean showResources) { this.showResources = showResources; }
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

Method declarations should be formatted consistently with proper spacing. Each method should be on separate lines with proper indentation for better readability.

Suggested change
public void setStartDate(Date startDate) { this.startDate = startDate; }
public boolean isShowResources() { return showResources; }
public void setShowResources(boolean showResources) { this.showResources = showResources; }
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public boolean isShowResources() {
return showResources;
}
public void setShowResources(boolean showResources) {
this.showResources = showResources;
}

Copilot uses AI. Check for mistakes.
Copy link
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


List<AccountVO> listAccounts(String accountName, Long domainId, Filter filter);

AccountVO findAccountByNameAndDomainIncludingRemoved(String accountName, Long domainId);
Copy link
Contributor

Choose a reason for hiding this comment

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

same as findAccountIncludingRemoved

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

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

@nvazquez
Copy link
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

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

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.