[
https://issues.apache.org/jira/browse/CLOUDSTACK-9161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15055789#comment-15055789
]
ASF GitHub Bot commented on CLOUDSTACK-9161:
--------------------------------------------
Github user agneya2001 commented on a diff in the pull request:
https://github.com/apache/cloudstack/pull/1240#discussion_r47481989
--- Diff:
plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaResponseBuilderImpl.java
---
@@ -186,7 +186,7 @@ public int compare(QuotaBalanceVO o1, QuotaBalanceVO
o2) {
//check that there is at least one balance entry
for (Iterator<QuotaBalanceVO> it = quotaBalance.iterator();
it.hasNext();) {
QuotaBalanceVO entry = it.next();
- if (entry.getCreditsId() > 0) {
+ if (entry.getCreditsId() == 0) {
--- End diff --
@DaanHoogland good that you are probing the logic.
In a system where quota service has never run, there could be credit
entries a admin may want to add some credit entries even before quota service
has run. So at a point the db can have credit entries without any real balance
entry. There could be a situation where there is a balance entry after several
credit entries followed by another set of credit entries.
When there is a balance entry it consolidates all the credit entries that
happened before it.
So when calculating balance you need to add all the credit entries that
happened after a balance entry while ignoring all the credit entries that
happened before the first balance entry. You till need to show all the credit
entries that happened in between for the balance statement.
When marvin tests were run the db was clean with only one credit entry.
This was a special case where you add all the credit entries to show the final
balance but you still need to show this credit entry in the balance statement.
If quota service has run once it makes a 0 balance entry as part of
bootstrapping.
entry.getCreditsId() == 0, looks for real balance entry. A credit id that
is non-zero refers to a credit entry with id being the credit id.
> Quota Service: fix marvin test
> ------------------------------
>
> Key: CLOUDSTACK-9161
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9161
> Project: CloudStack
> Issue Type: Bug
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Affects Versions: 4.7.0
> Reporter: Abhinandan Prateek
> Assignee: Abhinandan Prateek
> Priority: Critical
> Fix For: 4.7.0
>
>
> the two tests in test_quota.py marvin tests are failing.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)