Consider Quota settings during processing#10892
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10892 +/- ##
============================================
+ Coverage 16.30% 16.57% +0.26%
- Complexity 13450 13867 +417
============================================
Files 5675 5719 +44
Lines 499249 507216 +7967
Branches 60377 61577 +1200
============================================
+ Hits 81425 84088 +2663
- Misses 408753 413709 +4956
- Partials 9071 9419 +348
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@blueorangutan package |
|
@JoaoJandre 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 13585 |
Co-authored-by: Fabricio Duarte <fabricio.duarte.jr@gmail.com>
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the Quota plugin to respect per-account and per-domain enable/disable settings during usage processing and email alerts.
- Introduce
findConfigurationValueto read boolean config keys from account or domain details, falling back to defaults. - Update
shouldCalculateUsageRecordandisQuotaEmailTypeEnabledForAccountto use the new lookup. - Wire account/domain DAOs into Spring and adjust tests for the new method.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| framework/quota/src/test/java/org/apache/cloudstack/quota/QuotaAlertManagerImplTest.java | Remove old VO mock, update test setup to mock the new configuration lookup. |
| framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java | Add findConfigurationValue helper, inject AccountDetailsDao and DomainDetailsDao, and update usage logic. |
| framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManager.java | Declare new interface method findConfigurationValue. |
| framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaAlertManagerImpl.java | Replace direct config lookup with _quotaManager.findConfigurationValue. |
| engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-common-daos-between-management-and-usage-context.xml | Register beans for accountDetailsDaoImpl, domainDaoImpl, and domainDetailsDaoImpl. |
Comments suppressed due to low confidence (3)
framework/quota/src/test/java/org/apache/cloudstack/quota/QuotaAlertManagerImplTest.java:117
- The first test no longer mocks the new
findConfigurationValuecall, so it falls back to the default instead ofexpectedValue. AddMockito.when(quotaManagerMock.findConfigurationValue(accountMock, QuotaConfig.QuotaEnableEmails)).thenReturn(expectedValue)before invokingisQuotaEmailTypeEnabledForAccount.
boolean expectedValue = !QuotaConfig.QuotaEnableEmails.value();
framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java:362
- Missing import for
AccountVO. Addimport com.cloud.user.AccountVO;so the method signature compiles against the interface.
public boolean findConfigurationValue(AccountVO accountVO, ConfigKey<Boolean> key) {
engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-common-daos-between-management-and-usage-context.xml:32
- [nitpick] The
domainDaoImplbean is registered but not injected or used in the new code. Consider removing it to keep the Spring context lean.
<bean id="domainDaoImpl" class="com.cloud.domain.dao.DomainDaoImpl" />
|
@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 14203 |
|
@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-13798)
|
shwstppr
left a comment
There was a problem hiding this comment.
As far as I understand this might be a generic problem, ie,
ConfigKey.valueIn(accountId) not returning domain-level value when the config enable.account.settings.for.domain is set to true.
And a change should be added at the ConfigKey level itself.
Also, it will be worth checking if the behaviour has been fixed by 2a4a1f7 as Domain is considered PArent scope for Account scope now.
| return result; | ||
| } | ||
| } | ||
| boolean result = Boolean.parseBoolean(getConfigValueOrDefaultValue(key)); |
There was a problem hiding this comment.
key.value()
What is the difference?
if we call valueinscope() method, will it work @shwstppr ? |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
Consider Quota settings during processing
Description
Currently, when using the Quota plugin, it is possible to enable/disable the plugin specifically in the account settings. However, even if the plugin is disabled for the account, the setting is not considered because the Quota manager is failing to get its value, so that the account's Quota balance is always processed. This PR fixes this behavior.
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?