Skip to content

Commit abd7860

Browse files
committed
Merge pull request #873 from karuturi/CLOUDSTACK-8896
CLOUDSTACK-8896: allocated percentage of storage pool going beyond 100%This issue occurs when a volume in Ready state is moved across storage pools. While finding if the storage pool has enough space, it has a check to consider the size of non Ready volumes only. This is true if the volume to be attached to a vm is in the same storage pool. But, if the volume is in another storage pool and has to be moved to a vm's storage pool, the size of the volume should be considered in doing the space check. computing the asking size when volume is not in ready state or when the volume is on a different storage pool. Testing: I couldnt write unittests for it. This class is not in a unittestable state. manually tested in the below environment 1. xenserver 6.5 setup with 2 clusters and a host each in each of them. 2. added storage tags for the primary storage. 3. created two service offerings with the storage tags. 4. deployed two vms using newly created offerings in step 3. 5. at this stage, there are two vms one on each host with root disks on the corresponding primary. 6. create a data disk and attach it to vm1 7. detach the data disk. now the data disk is in the primary storage of the cluster of vm1 (let us say primary1) 8. attach this data disk to vm2(running on a host in different cluster) 9. the volume should be moved to the primary storage of another cluster and op_host_capacity should be accordingly updated. * pr/873: CLOUDSTACK-8896: allocated percentage of storage pool going beyond 100% Signed-off-by: Rajani Karuturi <rajani.karuturi@accelerite.com>
2 parents 01e78f9 + bec9115 commit abd7860

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

server/src/com/cloud/storage/StorageManagerImpl.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,9 @@ public boolean storagePoolHasEnoughSpace(List<Volume> volumes, StoragePool pool,
17191719
}
17201720

17211721
// allocated space includes templates
1722+
if(s_logger.isDebugEnabled()) {
1723+
s_logger.debug("Destination pool id: " + pool.getId());
1724+
}
17221725
StoragePoolVO poolVO = _storagePoolDao.findById(pool.getId());
17231726
long allocatedSizeWithTemplate = _capacityMgr.getAllocatedPoolCapacity(poolVO, null);
17241727
long totalAskingSize = 0;
@@ -1746,10 +1749,12 @@ public boolean storagePoolHasEnoughSpace(List<Volume> volumes, StoragePool pool,
17461749
allocatedSizeWithTemplate = _capacityMgr.getAllocatedPoolCapacity(poolVO, tmpl);
17471750
}
17481751
}
1749-
1750-
if (volumeVO.getState() != Volume.State.Ready) {
1751-
totalAskingSize += getDataObjectSizeIncludingHypervisorSnapshotReserve(volumeVO, pool);
1752-
1752+
// A ready state volume is already allocated in a pool. so the asking size is zero for it.
1753+
// In case the volume is moving across pools or is not ready yet, the asking size has to be computed
1754+
if (s_logger.isDebugEnabled()) {
1755+
s_logger.debug("pool id for the volume with id: " + volumeVO.getId() + " is " + volumeVO.getPoolId());
1756+
}
1757+
if ((volumeVO.getState() != Volume.State.Ready) || (volumeVO.getPoolId() != pool.getId())) {
17531758
if (ScopeType.ZONE.equals(poolVO.getScope()) && volumeVO.getTemplateId() != null) {
17541759
VMTemplateVO tmpl = _templateDao.findByIdIncludingRemoved(volumeVO.getTemplateId());
17551760

0 commit comments

Comments
 (0)