julien-vaz commented on code in PR #10892: URL: https://github.com/apache/cloudstack/pull/10892#discussion_r2161704880
########## framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java: ########## @@ -340,12 +349,41 @@ protected List<QuotaUsageVO> createQuotaUsagesAccordingToQuotaTariffs(AccountVO } protected boolean shouldCalculateUsageRecord(AccountVO accountVO, UsageVO usageRecord) { - if (Boolean.FALSE.equals(QuotaConfig.QuotaAccountEnabled.valueIn(accountVO.getAccountId()))) { + boolean calculateUsageRecord = findConfigurationValue(accountVO, QuotaConfig.QuotaAccountEnabled); + if (!calculateUsageRecord && usageRecord != null) { logger.debug("Considering usage record [{}] as calculated and skipping it because account [{}] has the quota plugin disabled.", usageRecord.toString(usageAggregationTimeZone), accountVO.reflectionToString()); return false; } - return true; + return calculateUsageRecord; + } + + @Override + public boolean findConfigurationValue(AccountVO accountVO, ConfigKey<Boolean> key) { + logger.trace("Searching configuration [{}] of account [{}] in its settings.", key.key(), accountVO); + AccountDetailVO accountDetail = accountDetailsDao.findDetail(accountVO.getAccountId(), key.key()); + if (accountDetail != null) { + boolean result = Boolean.parseBoolean(accountDetail.getValue()); + logger.trace("Using value [{}] found in account [{}] settings to configuration [{}].", result, accountVO, key.key()); + return result; + } + + if (Boolean.parseBoolean(_configDao.getValue("enable.account.settings.for.domain"))) { + logger.trace("Searching for configuration [{}] of account [{}] in its domain [{}] settings.", key.key(), accountVO, accountVO.getDomainId()); + DomainDetailVO domainDetail = domainDetailsDao.findDetail(accountVO.getDomainId(), key.key()); + if (domainDetail != null) { + boolean result = Boolean.parseBoolean(domainDetail.getValue()); + logger.trace("Using value [{}] found in domain [{}] settings to configuration [{}].", result, accountVO.getDomainId(), key.key()); + return result; + } + } + boolean result = Boolean.parseBoolean(getConfigValueOrDefaultValue(key)); + logger.trace("Using default value [{}] to configuration [{}].", result, key.key()); + return result; + } Review Comment: Hi, @DaanHoogland . The method `findConfigurationValue()` is being called only for the `quota.account.enabled` and `quota.enable.emails` global configurations. The method `valueInScope()` searches the configuration in the `ConfigCache` for the scope passed as argument, in this case `Account`. If it doesn't find it, it returns the value in global scope or parent scope. To decide which scope to use, it checks in the `scopes` parameter of `ConfigKey`. Since for both configurations the only scope defined is `Account`, `valueInScope()` returns the global value. So because the method always return a value, the `if` related to domain settings is never reached. I tested the `valueInScope()` with both configurations with a `Admin` account and a `Domain Admin` account in a subdomain. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org