mirror of
https://github.com/apache/cloudstack
synced 2026-08-28 16:36:07 +00:00
CLOUDSTACK-3376: NPE: resource count calculation from the account manager on account cleanup
This issue is happing because of the steps the code follow to cleanup the account.
The cleanupAccount was deleting the entries from the resource_limit and
resource_count table and performing further cleaning afterwards. Ideally, deletion
of entries from resourceLimit and resourceCount should be the last step in
cleanupAccount process.
Signed-off-by: Prasanna Santhanam <tsp@apache.org>
(cherry picked from commit 21b1c9449a)
This commit is contained in:
parent
f2d9a7b659
commit
c9548e3788
@ -732,16 +732,6 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
||||
int vlansReleased = _accountGuestVlanMapDao.removeByAccountId(accountId);
|
||||
s_logger.info("deleteAccount: Released " + vlansReleased + " dedicated guest vlan ranges from account " + accountId);
|
||||
|
||||
// Update resource count for this account and for parent domains.
|
||||
List<ResourceCountVO> resourceCounts = _resourceCountDao.listByOwnerId(accountId, ResourceOwnerType.Account);
|
||||
for (ResourceCountVO resourceCount : resourceCounts) {
|
||||
_resourceLimitMgr.decrementResourceCount(accountId, resourceCount.getType(), resourceCount.getCount());
|
||||
}
|
||||
|
||||
// Delete resource count and resource limits entries set for this account (if there are any).
|
||||
_resourceCountDao.removeEntriesByOwner(accountId, ResourceOwnerType.Account);
|
||||
_resourceLimitDao.removeEntriesByOwner(accountId, ResourceOwnerType.Account);
|
||||
|
||||
// release account specific acquired portable IP's. Since all the portable IP's must have been already
|
||||
// disassociated with VPC/guest network (due to deletion), so just mark portable IP as free.
|
||||
List<? extends IpAddress> portableIpsToRelease = _ipAddressDao.listByAccount(accountId);
|
||||
@ -759,6 +749,17 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Updating and deleting the resourceLimit and resourceCount should be the last step in cleanupAccount process.
|
||||
// Update resource count for this account and for parent domains.
|
||||
List<ResourceCountVO> resourceCounts = _resourceCountDao.listByOwnerId(accountId, ResourceOwnerType.Account);
|
||||
for (ResourceCountVO resourceCount : resourceCounts) {
|
||||
_resourceLimitMgr.decrementResourceCount(accountId, resourceCount.getType(), resourceCount.getCount());
|
||||
}
|
||||
|
||||
// Delete resource count and resource limits entries set for this account (if there are any).
|
||||
_resourceCountDao.removeEntriesByOwner(accountId, ResourceOwnerType.Account);
|
||||
_resourceLimitDao.removeEntriesByOwner(accountId, ResourceOwnerType.Account);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
s_logger.warn("Failed to cleanup account " + account + " due to ", ex);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user