You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by de...@apache.org on 2013/07/19 12:44:14 UTC

[1/3] git commit: updated refs/heads/master to 3771e8a

Updated Branches:
  refs/heads/master 34c6c023e -> 3771e8a0e


CLOUDSTACK-2510: Getting NPE while executinng listStoragePools API command.


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

Branch: refs/heads/master
Commit: 6e63f10a4f4f77c1b57f1e804b44445a443c6b75
Parents: 34c6c02
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Tue Jul 2 10:45:49 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Fri Jul 19 16:02:08 2013 +0530

----------------------------------------------------------------------
 .../lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java          | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6e63f10a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
index 26733d4..17e80b8 100644
--- a/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
+++ b/plugins/storage/volume/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java
@@ -364,6 +364,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
         List<HostVO> allHosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, primarystore.getClusterId(),
                 primarystore.getPodId(), primarystore.getDataCenterId());
         if (allHosts.isEmpty()) {
+            primaryDataStoreDao.expunge(primarystore.getId());
             throw new CloudRuntimeException("No host up to associate a storage pool with in cluster "
                     + primarystore.getClusterId());
         }


[3/3] git commit: updated refs/heads/master to 3771e8a

Posted by de...@apache.org.
CLOUDSTACK-3496: [Regression]Primary Storage resource usage is not getting updated if detached volume is deleted


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

Branch: refs/heads/master
Commit: 3771e8a0e61385aa6bda0fd73afa961b6a6cb091
Parents: 539eb38
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Mon Jul 15 14:37:54 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Fri Jul 19 16:04:36 2013 +0530

----------------------------------------------------------------------
 server/src/com/cloud/storage/VolumeManagerImpl.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3771e8a0/server/src/com/cloud/storage/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeManagerImpl.java b/server/src/com/cloud/storage/VolumeManagerImpl.java
index 0f7086b..7b44c5c 100644
--- a/server/src/com/cloud/storage/VolumeManagerImpl.java
+++ b/server/src/com/cloud/storage/VolumeManagerImpl.java
@@ -1342,7 +1342,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
                             ResourceType.volume);
                     /* If volume is in primary storage, decrement primary storage count else decrement secondary
                      storage count (in case of upload volume). */
-                    if (volume.getFolder() != null || volume.getState() == Volume.State.Allocated) {
+                    if (volume.getFolder() != null || volume.getPath() != null || volume.getState() == Volume.State.Allocated) {
                         _resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.primary_storage,
                                 new Long(volume.getSize()));
                     } else {


[2/3] git commit: updated refs/heads/master to 3771e8a

Posted by de...@apache.org.
CLOUDSTACK-3492: [Regression]Update Resource Count for an account is updating the primary storage incorretly.

The issue is that while calculating the used primary storage size, the updateResourceCount
API is also calculating the disk size of virtual router VM, created for that account and
because of this, the API is returning the incorrect result.


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

Branch: refs/heads/master
Commit: 539eb38908ede53a36d4bb680b848caf9fe469c4
Parents: 6e63f10
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Tue Jul 16 14:52:56 2013 +0530
Committer: Devdeep Singh <de...@gmail.com>
Committed: Fri Jul 19 16:04:10 2013 +0530

----------------------------------------------------------------------
 .../src/com/cloud/storage/dao/VolumeDao.java    |  3 ++-
 .../com/cloud/storage/dao/VolumeDaoImpl.java    | 13 ++++++++++--
 .../src/com/cloud/vm/dao/VMInstanceDao.java     |  2 +-
 .../src/com/cloud/vm/dao/VMInstanceDaoImpl.java | 22 ++++++++++----------
 .../resourcelimit/ResourceLimitManagerImpl.java |  5 +++--
 5 files changed, 28 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/539eb389/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
index fb7dc70..7b58e7d 100755
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
@@ -80,9 +80,10 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
      * Gets the Total Primary Storage space allocated for an account
      * 
      * @param account
+     * @param list of ids of virtual router VMs under this account
      * @return total Primary Storage space (in bytes) used
      */
-    long primaryStorageUsedForAccount(long accountId);
+    long primaryStorageUsedForAccount(long accountId, List<Long> virtualRouters);
 
     /**
      * Gets the Total Secondary Storage space used by volumes allocated for an

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/539eb389/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
index ba85466..f87cd4e 100755
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -318,7 +318,10 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
         primaryStorageSearch = createSearchBuilder(SumCount.class);
         primaryStorageSearch.select("sum", Func.SUM, primaryStorageSearch.entity().getSize());
         primaryStorageSearch.and("accountId", primaryStorageSearch.entity().getAccountId(), Op.EQ);
-        primaryStorageSearch.and("path", primaryStorageSearch.entity().getPath(), Op.NNULL);
+        primaryStorageSearch.and("virtualRouterVmIds", primaryStorageSearch.entity().getInstanceId(), Op.NIN);
+        primaryStorageSearch.and().op("path", primaryStorageSearch.entity().getPath(), Op.NNULL);
+        primaryStorageSearch.or("states", primaryStorageSearch.entity().getState(), Op.IN);
+        primaryStorageSearch.cp();
         primaryStorageSearch.and("isRemoved", primaryStorageSearch.entity().getRemoved(), Op.NULL);
         primaryStorageSearch.done();
 
@@ -326,6 +329,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
         secondaryStorageSearch.select("sum", Func.SUM, secondaryStorageSearch.entity().getSize());
         secondaryStorageSearch.and("accountId", secondaryStorageSearch.entity().getAccountId(), Op.EQ);
         secondaryStorageSearch.and("path", secondaryStorageSearch.entity().getPath(), Op.NULL);
+        secondaryStorageSearch.and("states", secondaryStorageSearch.entity().getState(), Op.NIN);
         secondaryStorageSearch.and("isRemoved", secondaryStorageSearch.entity().getRemoved(), Op.NULL);
         secondaryStorageSearch.done();
     }
@@ -349,9 +353,13 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
     }
 
     @Override
-    public long primaryStorageUsedForAccount(long accountId) {
+    public long primaryStorageUsedForAccount(long accountId, List<Long> virtualRouters) {
         SearchCriteria<SumCount> sc = primaryStorageSearch.create();
         sc.setParameters("accountId", accountId);
+        if (!virtualRouters.isEmpty()) {
+            sc.setParameters("virtualRouterVmIds", virtualRouters.toArray(new Object[virtualRouters.size()]));
+        }
+        sc.setParameters("states", State.Allocated);
         List<SumCount> storageSpace = customSearch(sc, null);
         if (storageSpace != null) {
             return storageSpace.get(0).sum;
@@ -364,6 +372,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
     public long secondaryStorageUsedForAccount(long accountId) {
         SearchCriteria<SumCount> sc = secondaryStorageSearch.create();
         sc.setParameters("accountId", accountId);
+        sc.setParameters("states", State.Allocated);
         List<SumCount> storageSpace = customSearch(sc, null);
         if (storageSpace != null) {
             return storageSpace.get(0).sum;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/539eb389/engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java b/engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java
index e564052..2fe8140 100644
--- a/engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java
+++ b/engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java
@@ -90,7 +90,7 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
     List<VMInstanceVO> listByTypeAndState(VirtualMachine.Type type, State state);
 
     List<VMInstanceVO> listByAccountId(long accountId);
-    public Long countAllocatedVirtualRoutersForAccount(long accountId);
+    public List<Long> findIdsOfAllocatedVirtualRoutersForAccount(long accountId);
 
     List<VMInstanceVO> listByClusterId(long clusterId);  // this does not pull up VMs which are starting
     List<VMInstanceVO> listLHByClusterId(long clusterId);  // get all the VMs even starting one on this cluster

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/539eb389/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
index ec04085..8cbc6b6 100644
--- a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
@@ -79,7 +79,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
     protected SearchBuilder<VMInstanceVO> HostUpSearch;
     protected SearchBuilder<VMInstanceVO> InstanceNameSearch;
     protected SearchBuilder<VMInstanceVO> HostNameSearch;
-    protected GenericSearchBuilder<VMInstanceVO, Long> CountVirtualRoutersByAccount;
+    protected GenericSearchBuilder<VMInstanceVO, Long> FindIdsOfVirtualRoutersByAccount;
     protected GenericSearchBuilder<VMInstanceVO, Long> CountRunningByHost;
     protected GenericSearchBuilder<VMInstanceVO, Long> CountRunningByAccount;
     protected SearchBuilder<VMInstanceVO> NetworkTypeSearch;
@@ -197,12 +197,12 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
         HostNameSearch.and("hostName", HostNameSearch.entity().getHostName(), Op.EQ);
         HostNameSearch.done();
 
-        CountVirtualRoutersByAccount = createSearchBuilder(Long.class);
-        CountVirtualRoutersByAccount.select(null, Func.COUNT, null);
-        CountVirtualRoutersByAccount.and("account", CountVirtualRoutersByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
-        CountVirtualRoutersByAccount.and("type", CountVirtualRoutersByAccount.entity().getType(), SearchCriteria.Op.EQ);
-        CountVirtualRoutersByAccount.and("state", CountVirtualRoutersByAccount.entity().getState(), SearchCriteria.Op.NIN);
-        CountVirtualRoutersByAccount.done();
+        FindIdsOfVirtualRoutersByAccount = createSearchBuilder(Long.class);
+        FindIdsOfVirtualRoutersByAccount.selectField(FindIdsOfVirtualRoutersByAccount.entity().getId());
+        FindIdsOfVirtualRoutersByAccount.and("account", FindIdsOfVirtualRoutersByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
+        FindIdsOfVirtualRoutersByAccount.and("type", FindIdsOfVirtualRoutersByAccount.entity().getType(), SearchCriteria.Op.EQ);
+        FindIdsOfVirtualRoutersByAccount.and("state", FindIdsOfVirtualRoutersByAccount.entity().getState(), SearchCriteria.Op.NIN);
+        FindIdsOfVirtualRoutersByAccount.done();
 
         CountRunningByHost = createSearchBuilder(Long.class);
         CountRunningByHost.select(null, Func.COUNT, null);
@@ -441,12 +441,12 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
 	}
 
     @Override
-    public Long countAllocatedVirtualRoutersForAccount(long accountId) {
-    	SearchCriteria<Long> sc = CountVirtualRoutersByAccount.create();
+    public List<Long> findIdsOfAllocatedVirtualRoutersForAccount(long accountId) {
+        SearchCriteria<Long> sc = FindIdsOfVirtualRoutersByAccount.create();
         sc.setParameters("account", accountId);
         sc.setParameters("type", VirtualMachine.Type.DomainRouter);
-		sc.setParameters("state", new Object[] {State.Destroyed, State.Error, State.Expunging});
-        return customSearch(sc, null).get(0);
+        sc.setParameters("state", new Object[] {State.Destroyed, State.Error, State.Expunging});
+        return customSearch(sc, null);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/539eb389/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
index 665c2e1..bfa6981 100755
--- a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
+++ b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
@@ -820,7 +820,7 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
             newCount = _userVmDao.countAllocatedVMsForAccount(accountId);
         } else if (type == Resource.ResourceType.volume) {
             newCount = _volumeDao.countAllocatedVolumesForAccount(accountId);
-            long virtualRouterCount = _vmDao.countAllocatedVirtualRoutersForAccount(accountId);
+            long virtualRouterCount = _vmDao.findIdsOfAllocatedVirtualRoutersForAccount(accountId).size();
             newCount = newCount - virtualRouterCount; // don't count the volumes of virtual router
         } else if (type == Resource.ResourceType.snapshot) {
             newCount = _snapshotDao.countSnapshotsForAccount(accountId);
@@ -839,7 +839,8 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
         } else if (type == Resource.ResourceType.memory) {
             newCount = calculateMemoryForAccount(accountId);
         } else if (type == Resource.ResourceType.primary_storage) {
-            newCount = _volumeDao.primaryStorageUsedForAccount(accountId);
+            List<Long> virtualRouters = _vmDao.findIdsOfAllocatedVirtualRoutersForAccount(accountId);
+            newCount = _volumeDao.primaryStorageUsedForAccount(accountId, virtualRouters);
         } else if (type == Resource.ResourceType.secondary_storage) {
             newCount = calculateSecondaryStorageForAccount(accountId);
         } else {