stag7824 commented on code in PR #14293:
URL: https://github.com/apache/cloudstack/pull/14293#discussion_r4263036017


##########
server/src/main/java/com/cloud/api/query/dao/DomainJoinDaoImpl.java:
##########
@@ -217,24 +217,24 @@ public void setResourceLimits(DomainJoinVO domain, 
boolean fullView, ResourceLim
 
         //get resource limits for backups
         long backupLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getBackupLimit(), 
ResourceType.backup, domain.getId());
-        String backupLimitDisplay = (fullView || snapshotLimit == -1) ? 
Resource.UNLIMITED : String.valueOf(backupLimit);
+        String backupLimitDisplay = (fullView || backupLimit == -1) ? 
Resource.UNLIMITED : String.valueOf(backupLimit);
         long backupTotal = (domain.getBackupTotal() == null) ? 0 : 
domain.getBackupTotal();
-        String backupAvail = (fullView || snapshotLimit == -1) ? 
Resource.UNLIMITED : String.valueOf(backupLimit - backupTotal);
+        String backupAvail = (fullView || backupLimit == -1) ? 
Resource.UNLIMITED : String.valueOf(backupLimit - backupTotal);
         response.setBackupLimit(backupLimitDisplay);
         response.setBackupTotal(backupTotal);
         response.setBackupAvailable(backupAvail);
 
         //get resource limits for backup storage space and convert it from 
Bytes to GiB
         long backupStorageLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getBackupStorageLimit(), 
ResourceType.backup_storage, domain.getId());
-        String backupStorageLimitDisplay = (fullView || backupLimit == -1) ? 
Resource.UNLIMITED : String.valueOf(backupStorageLimit / 
ResourceType.bytesToGiB);
+        String backupStorageLimitDisplay = (fullView || backupStorageLimit == 
-1) ? Resource.UNLIMITED : String.valueOf(backupStorageLimit / 
ResourceType.bytesToGiB);
         long backupStorageTotal = (domain.getBackupStorageTotal() == null) ? 0 
: (domain.getBackupStorageTotal() / ResourceType.bytesToGiB);
         String backupStorageAvail = (fullView || backupStorageLimit == -1) ? 
Resource.UNLIMITED : String.valueOf((backupStorageLimit / 
ResourceType.bytesToGiB) - backupStorageTotal);
         response.setBackupStorageLimit(backupStorageLimitDisplay);
         response.setBackupStorageTotal(backupStorageTotal);
         response.setBackupStorageAvailable(backupStorageAvail);
 
         //get resource limits for buckets
-        long bucketLimit = 
ApiDBUtils.findCorrectResourceLimit(domain.getBucketLimit(), domain.getId(), 
ResourceType.bucket);
+        long bucketLimit = 
ApiDBUtils.findCorrectResourceLimitForDomain(domain.getBucketLimit(), 
ResourceType.bucket, domain.getId());

Review Comment:
   Good catch, you're right. When a domain has no limit of its own, 
`ApiDBUtils.findCorrectResourceLimitForDomain(Long, ResourceType, long)` fell 
back to `findDefaultResourceLimitForDomain`, which only applies the 
`max.domain.*` default to storage types and returns unlimited for everything 
else, while enforcement uses 
`ResourceLimitService.findCorrectResourceLimitForDomain` (parent domain's 
limit, then the default). So it wasn't only buckets: IPs, volumes, snapshots, 
networks, CPU and memory showed unlimited the same way; VMs looked right 
because they already go through the other overload.
   
   I've pushed a change (8f6592a) so that fallback uses the same lookup as 
enforcement, with a unit test that fails without it (`expected:<20> but 
was:<-1>`). One thing to be aware of: this means a domain without its own 
limits will now show the inherited or default limits for those types instead of 
"Unlimited", which is what's actually enforced.
   



-- 
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]

Reply via email to