stag7824 opened a new pull request, #14293: URL: https://github.com/apache/cloudstack/pull/14293
### Description Fixes #13944 `listDomains` reports the bucket and object storage limits of every non-root domain as `Unlimited`, whatever has been configured. @ms30063600's re-test on #13944 shows it clearly: all 17 limits read back correctly from `listResourceLimits`, but the usage view (which reads `listDomains`) shows Bucket and Object Storage as Unlimited. `DomainJoinDaoImpl.setResourceLimits` resolves those two types through the **account** helper: ```java long bucketLimit = ApiDBUtils.findCorrectResourceLimit(domain.getBucketLimit(), domain.getId(), ResourceType.bucket); long objectStorageLimit = ApiDBUtils.findCorrectResourceLimit(domain.getObjectStorageLimit(), domain.getId(), ResourceType.object_storage); ``` `findCorrectResourceLimit(limit, accountId, type)` delegates to `ResourceLimitManagerImpl.findCorrectResourceLimitForAccount`, which first checks `isRootAdmin(accountId)` and then `_accountDao.findById(accountId)`, returning unlimited for either. Passed a domain id, it is looking up an unrelated account — typically the root admin (account 2 vs. a domain with id 2) or nothing at all — so the configured limit is never reached. The other fifteen types in this method already use `findCorrectResourceLimitForDomain`; this changes the two outliers to match. While in there, the backup rows had their unlimited checks copied from the row above: ```java String backupLimitDisplay = (fullView || snapshotLimit == -1) ? ... // should be backupLimit String backupAvail = (fullView || snapshotLimit == -1) ? ... // should be backupLimit String backupStorageLimitDisplay = (fullView || backupLimit == -1) ? ... // should be backupStorageLimit ``` so a domain with unlimited snapshots shows its backup limit as Unlimited, and one with unlimited backups shows its backup storage limit as Unlimited. `AccountJoinDaoImpl` does not have either problem. ### Types of changes - [x] Bug fix (non-breaking change which fixes an issue) ### Feature/Enhancement Scale or Bug Severity #### Bug Severity - [x] Minor ### How Has This Been Tested? Added `DomainJoinDaoImplTest`, which calls `setResourceLimits` directly with `ApiDBUtils` stubbed (the domain lookup returns the domain's own limit; the account lookup returns unlimited, as it does in practice for a domain id) and verifies the values set on the response: - bucket 147 and object storage 157 GiB are reported as `147` / `157` - backup 127 is reported while the snapshot limit is unlimited - backup storage 137 GiB is reported while the backup limit is unlimited ``` mvn test -pl server -Dtest=DomainJoinDaoImplTest Tests run: 3, Failures: 0, Errors: 0, Skipped: 0 ``` Without the change to `DomainJoinDaoImpl`, all three fail. `mvn checkstyle:check -pl server` reports no violations. I do not have a live environment to check the UI against, so this is unit-level; the reporter's JSON and screenshots on #13944 are the end-to-end reproduction. One thing I could not explain from the code: the same screenshot shows VPC as "77 Available" but "0 / 67". Both values come from the same `vpcLimit` variable in this method, so that mismatch does not originate here and this PR does not address it. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
