cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chipchild...@apache.org
Subject [39/50] [abbrv] git commit: updated refs/heads/ldapplugin to 7bc705e
Date Wed, 17 Jul 2013 17:35:38 GMT
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>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/21b1c944
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/21b1c944
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/21b1c944

Branch: refs/heads/ldapplugin
Commit: 21b1c9449a1289db9fa92c2ec76a936006100ab3
Parents: 5fbec76
Author: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Authored: Fri Jul 12 14:11:36 2013 +0530
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Wed Jul 17 12:39:16 2013 +0530

----------------------------------------------------------------------
 .../src/com/cloud/user/AccountManagerImpl.java  | 21 ++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/21b1c944/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index 4b06e78..512f913 100755
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -734,16 +734,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);
@@ -761,6 +751,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);


Mime
View raw message