Skip to content

Commit e992a25

Browse files
Alena ProkharchykAlena Prokharchyk
authored andcommitted
bug 14033: root/domain admin limits are always Unlimited. Return it as Unlimited in listResourceLimit response
status 14033: resolved fixed
1 parent 25676aa commit e992a25

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import com.cloud.configuration.Resource.ResourceType;
4040
import com.cloud.configuration.ResourceCount;
4141
import com.cloud.configuration.ResourceCountVO;
42+
import com.cloud.configuration.ResourceLimit;
4243
import com.cloud.configuration.ResourceLimitVO;
4344
import com.cloud.configuration.dao.ConfigurationDao;
4445
import com.cloud.configuration.dao.ResourceCountDao;
@@ -205,6 +206,12 @@ public void decrementResourceCount(long accountId, ResourceType type, Long... de
205206
public long findCorrectResourceLimitForAccount(Account account, ResourceType type) {
206207

207208
long max = Resource.RESOURCE_UNLIMITED; // if resource limit is not found, then we treat it as unlimited
209+
210+
//no limits for Admin accounts
211+
if (_accountMgr.isAdmin(account.getType())) {
212+
return max;
213+
}
214+
208215
ResourceLimitVO limit = _resourceLimitDao.findByOwnerIdAndType(account.getId(), ResourceOwnerType.Account, type);
209216

210217
// Check if limit is configured for account
@@ -496,9 +503,14 @@ public ResourceLimitVO updateResourceLimit(Long accountId, Long domainId, Intege
496503

497504
if (accountId != null) {
498505
Account account = _entityMgr.findById(Account.class, accountId);
499-
if (account.getType() == Account.ACCOUNT_ID_SYSTEM) {
506+
if (account.getId() == Account.ACCOUNT_ID_SYSTEM) {
500507
throw new InvalidParameterValueException("Can't update system account");
501508
}
509+
510+
//only Unlimited value is accepted if account is Admin
511+
if (_accountMgr.isAdmin(account.getType()) && max.shortValue() != ResourceLimit.RESOURCE_UNLIMITED) {
512+
throw new InvalidParameterValueException("Only " + ResourceLimit.RESOURCE_UNLIMITED + " limit is supported for Admin accounts");
513+
}
502514

503515
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
504516
_accountMgr.checkAccess(caller, AccessType.ModifyProject, true, account);

0 commit comments

Comments
 (0)