-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Create API to list Quota credits #9590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create API to list Quota credits #9590
Conversation
|
@blueorangutan package |
|
@winterhazel 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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9590 +/- ##
============================================
+ Coverage 16.07% 16.08% +0.01%
- Complexity 12890 12914 +24
============================================
Files 5642 5643 +1
Lines 494087 494196 +109
Branches 59931 59940 +9
============================================
+ Hits 79425 79514 +89
- Misses 405844 405863 +19
- Partials 8818 8819 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10810 |
JoaoJandre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, did not test it
|
@blueorangutan test keepEnv |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-11210)
|
|
@winterhazel , I think this is good to go safe one concern; removing response data from an API response is a backwards incompatibility. I can not judge the gravity (and haven't tested this PR and am not a quota user so just take my concern a little seriously ;) but the principle should only be broken after careful consideration. Can you give some stronger arguments than consistency for removing it, please? |
|
Hey @DaanHoogland, my idea of removing the credits listing from Regarding the gravity of removing it: Quota users would be advised to use As it would definitely have an impact, I understand why we would want to keep this information in the response, so I'm okay with not removing it. The enhancements to |
|
ok, @winterhazel . I know you and your are the most heavy users of quota so I am not going to -1 this by any means, but my advice would be to leave it in and shout about removing it before you do. you might get work mitigating any regressions if you don't. |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
|
@blueorangutan package |
|
@winterhazel 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. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 11731 |
bernardodemarco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Verified that I was able to list the credits of a domain recursively.
quota creditslist domainid=6b5335fb-4b6f-11ef-87b4-cec422422af1 isrecursive=true
(acs-all-in-one) 🦐 > quota creditslist domainid=6b5335fb-4b6f-11ef-87b4-cec422422af1 isrecursive=true
{
"count": 4,
"credit": [
{
"credit": 100,
"creditedon": "2025-01-06T15:45:02+0000",
"creditoruserid": "203addbc-4b71-11ef-87b4-cec422422af1",
"creditorusername": "admin",
"currency": "$"
},
{
"credit": 150,
"creditedon": "2025-01-06T15:59:31+0000",
"creditoruserid": "e2976938-6853-4f2f-8e71-c974647771e1",
"creditorusername": "d1",
"currency": "$"
},
{
"credit": 175,
"creditedon": "2025-01-06T15:59:59+0000",
"creditoruserid": "203addbc-4b71-11ef-87b4-cec422422af1",
"creditorusername": "admin",
"currency": "$"
},
{
"credit": 250,
"creditedon": "2025-01-06T16:00:21+0000",
"creditoruserid": "203addbc-4b71-11ef-87b4-cec422422af1",
"creditorusername": "admin",
"currency": "$"
}
]
}Verified that, when the isrecursive parameter is false, only the credits related to the specified domainid are listed.
quota creditslist domainid=6b5335fb-4b6f-11ef-87b4-cec422422af1 isrecursive=false
(acs-all-in-one) 🐝 > quota creditslist domainid=6b5335fb-4b6f-11ef-87b4-cec422422af1 isrecursive=false
{
"count": 2,
"credit": [
{
"credit": 100,
"creditedon": "2025-01-06T15:45:02+0000",
"creditoruserid": "203addbc-4b71-11ef-87b4-cec422422af1",
"creditorusername": "admin",
"currency": "$"
},
{
"credit": 250,
"creditedon": "2025-01-06T16:00:21+0000",
"creditoruserid": "203addbc-4b71-11ef-87b4-cec422422af1",
"creditorusername": "admin",
"currency": "$"
}
]
}Verified that the startdate and enddate filters are working as expected.
quota creditslist domainid=6b5335fb-4b6f-11ef-87b4-cec422422af1 isrecursive=true startdate="2025-01-06T12:55:00-0300" enddate="2025-01-06T13:00:00-0300"
(acs-all-in-one) 🐤 > quota creditslist domainid=6b5335fb-4b6f-11ef-87b4-cec422422af1 isrecursive=true startdate="2025-01-06T12:55:00-0300" enddate="2025-01-06T13:00:00-0300"
{
"count": 2,
"credit": [
{
"credit": 150,
"creditedon": "2025-01-06T15:59:31+0000",
"creditoruserid": "e2976938-6853-4f2f-8e71-c974647771e1",
"creditorusername": "d1",
"currency": "$"
},
{
"credit": 175,
"creditedon": "2025-01-06T15:59:59+0000",
"creditoruserid": "203addbc-4b71-11ef-87b4-cec422422af1",
"creditorusername": "admin",
"currency": "$"
}
]
}Verified that the validation of the credits access is working as expected.
quota creditslist domainid=1495812e-ccfa-4d3f-ad3e-6ad8b101c7cd
(acs-all-in-one) 🐗 > quota creditslist domainid=1495812e-ccfa-4d3f-ad3e-6ad8b101c7cd
🙈 Error: (HTTP 531, error code 4365) Account d1 does not have permission to operate within domain id=1495812e-ccfa-4d3f-ad3e-6ad8b101c7cd
...ns/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaCreditsResponse.java
Show resolved
Hide resolved
…/response/QuotaCreditsResponse.java Co-authored-by: Bernardo De Marco Gonçalves <[email protected]>
|
@blueorangutan package |
|
@DaanHoogland 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. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12004 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-12057)
|
|
applying insanity |
|
@blueorangutan test keepEnv |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-12058)
|
|
test_vm_life_cycle has a more generic problem especially in the secure chapter. The errors are different both times and probably environmental by nature. |
@winterhazel , clear, your call..! |
This one should be good for merge as well 🙂 |
Description
When credits are added to an account, an entry that represents the operation is created in
cloud_usage.quota_credits. Some information about these entries is currently returned alongside an account's balance through thequotaBalanceAPI. However, this is not consistent with the API's purpose (viewing an account's balance), and it is not possible to view the credit addition history for a whole domain with a single API call.In order to make
quotaBalancemore consistent with its purpose, the credit addition history will be removed from its response alongside some enhancements to the API in the future. To list the credit addition history, this PR adds thequotaCreditsList, which has the following parameters:accountid: ID of the account for which the credit statement will be generated.domainid: ID of the domain for which credit statement will be generated. Available only for administrators.isrecursive: Whether to generate the credit statement for the provided domain and its children. Defaults to false.startdate: Start date of the statement. If not provided, the first day of the current month will be considered as the start date.enddate: End date of the statement. If not provided, the current date will be considered as the end date.No parameters are flagged as required, but at least
accountidordomainidmust be provided.Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
How Has This Been Tested?
In my environment, there were the following domains and accounts:
ROOT: admin (root admin)ROOT/d1: d1 (domain admin), u1 (user)First, in the root admin account, I added 100 credits to the three accounts; in the domain admin account, I added credits to d1 and u1. Then, I tested the behavior of the API for each account.
For the root admin account:
accountidtested).enddatetested).startdatetested).ROOT's credits and verified that the response had the expected results (domainidtested).ROOT's credits recursively and verified that the response had the expected results (isrecursivetested).For the domain admin account:
ROOT/d1's credits history and verified that the response had the expected results.For the user account:
ROOT/d1and verified that my permission was denied.