sureshanaparti commented on a change in pull request #4388:
URL: https://github.com/apache/cloudstack/pull/4388#discussion_r501680506



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1930,18 +1931,13 @@ private boolean upgradeRunningVirtualMachine(Long vmId, 
Long newServiceOfferingI
     public HashMap<String, VolumeStatsEntry> getVolumeStatistics(long 
clusterId, String poolUuid, StoragePoolType poolType, List<String> 
volumeLocators, int timeout) {
         List<HostVO> neighbors = 
_resourceMgr.listHostsInClusterByStatus(clusterId, Status.Up);
         StoragePoolVO storagePool = _storagePoolDao.findPoolByUUID(poolUuid);
-        for (HostVO neighbor : neighbors) {
-            // apply filters:
-            // - managed storage
-            // - local storage
-            if (storagePool.isManaged() || storagePool.isLocal()) {

Review comment:
       @slavkap what is the impact on volume stats for managed / local storage 
pool ? can this cause regression?

##########
File path: server/src/main/java/com/cloud/api/query/ViewResponseHelper.java
##########
@@ -287,10 +287,7 @@
             vrDataList.put(vr.getId(), vrData);
 
             VolumeStats vs = null;
-            if (vr.getFormat() == ImageFormat.QCOW2) {
-                vs = ApiDBUtils.getVolumeStatistics(vrData.getId());
-            }
-            else if (vr.getFormat() == ImageFormat.VHD){
+            if (vr.getFormat() == ImageFormat.VHD || vr.getFormat() == 
ImageFormat.QCOW2){

Review comment:
       ```suggestion
               if (vr.getFormat() == ImageFormat.VHD || vr.getFormat() == 
ImageFormat.QCOW2) {
   ```

##########
File path: engine/schema/src/main/java/com/cloud/dc/dao/ClusterDaoImpl.java
##########
@@ -81,7 +81,6 @@ public ClusterDaoImpl() {
 
         ZoneSearch = createSearchBuilder();
         ZoneSearch.and("dataCenterId", ZoneSearch.entity().getDataCenterId(), 
SearchCriteria.Op.EQ);
-        ZoneSearch.groupBy(ZoneSearch.entity().getHypervisorType());

Review comment:
       @slavkap check if this can cause regression, for listing hypervisors for 
zone.

##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1956,16 +1952,16 @@ private boolean upgradeRunningVirtualMachine(Long vmId, 
Long newServiceOfferingI
 
             if (answer instanceof GetVolumeStatsAnswer){
                 GetVolumeStatsAnswer volstats = (GetVolumeStatsAnswer)answer;
-                return volstats.getVolumeStats();
+                volumeStatsByUuid.putAll(volstats.getVolumeStats());
             }
         }
-        return null;
+        return volumeStatsByUuid.size() > 0 ? volumeStatsByUuid : null;
     }
 
     private List<String> getVolumesByHost(HostVO host, StoragePool pool){
-        List<UserVmVO> vmsPerHost = _vmDao.listByHostId(host.getId());
+        List<VMInstanceVO> vmsPerHost = 
_vmInstanceDao.listByHostId(host.getId());
         return vmsPerHost.stream()
-                .flatMap(vm -> 
_volsDao.findByInstanceIdAndPoolId(vm.getId(),pool.getId()).stream().map(vol -> 
vol.getPath()))
+                .flatMap(vm -> 
_volsDao.findByInstanceIdAndPoolId(vm.getId(),pool.getId()).stream().map(vol -> 
vol.getState() == Volume.State.Ready ? vol.getPath() : 
null).filter(Objects::nonNull))

Review comment:
       @slavkap volume path is not the locator for OVA format, update with 
chain info ?

##########
File path: engine/schema/src/main/java/com/cloud/dc/dao/ClusterDaoImpl.java
##########
@@ -81,7 +81,6 @@ public ClusterDaoImpl() {
 
         ZoneSearch = createSearchBuilder();
         ZoneSearch.and("dataCenterId", ZoneSearch.entity().getDataCenterId(), 
SearchCriteria.Op.EQ);
-        ZoneSearch.groupBy(ZoneSearch.entity().getHypervisorType());

Review comment:
       @slavkap list hypervisors should return only 1 KVM.

##########
File path: engine/schema/src/main/java/com/cloud/dc/dao/ClusterDaoImpl.java
##########
@@ -81,7 +81,6 @@ public ClusterDaoImpl() {
 
         ZoneSearch = createSearchBuilder();
         ZoneSearch.and("dataCenterId", ZoneSearch.entity().getDataCenterId(), 
SearchCriteria.Op.EQ);
-        ZoneSearch.groupBy(ZoneSearch.entity().getHypervisorType());

Review comment:
       @slavkap list hypervisors should return only 1 KVM, that is the reason 
for group by.

##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1956,16 +1952,16 @@ private boolean upgradeRunningVirtualMachine(Long vmId, 
Long newServiceOfferingI
 
             if (answer instanceof GetVolumeStatsAnswer){
                 GetVolumeStatsAnswer volstats = (GetVolumeStatsAnswer)answer;
-                return volstats.getVolumeStats();
+                volumeStatsByUuid.putAll(volstats.getVolumeStats());
             }
         }
-        return null;
+        return volumeStatsByUuid.size() > 0 ? volumeStatsByUuid : null;
     }
 
     private List<String> getVolumesByHost(HostVO host, StoragePool pool){
-        List<UserVmVO> vmsPerHost = _vmDao.listByHostId(host.getId());
+        List<VMInstanceVO> vmsPerHost = 
_vmInstanceDao.listByHostId(host.getId());
         return vmsPerHost.stream()
-                .flatMap(vm -> 
_volsDao.findByInstanceIdAndPoolId(vm.getId(),pool.getId()).stream().map(vol -> 
vol.getPath()))
+                .flatMap(vm -> 
_volsDao.findByInstanceIdAndPoolId(vm.getId(),pool.getId()).stream().map(vol -> 
vol.getState() == Volume.State.Ready ? vol.getPath() : 
null).filter(Objects::nonNull))

Review comment:
       ok @slavkap  you have corrected the volume locator for QCOW2 in the 
response helper, this would be similar change for OVA here.

##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -1930,18 +1931,13 @@ private boolean upgradeRunningVirtualMachine(Long vmId, 
Long newServiceOfferingI
     public HashMap<String, VolumeStatsEntry> getVolumeStatistics(long 
clusterId, String poolUuid, StoragePoolType poolType, List<String> 
volumeLocators, int timeout) {
         List<HostVO> neighbors = 
_resourceMgr.listHostsInClusterByStatus(clusterId, Status.Up);
         StoragePoolVO storagePool = _storagePoolDao.findPoolByUUID(poolUuid);
-        for (HostVO neighbor : neighbors) {
-            // apply filters:
-            // - managed storage
-            // - local storage
-            if (storagePool.isManaged() || storagePool.isLocal()) {

Review comment:
       @slavkap For non-managed & shared pools, the `volumeLocators` passed to 
the method is directly used earlier, instead from the host(s). Now, 
`volumeLocators` in the method arg, is not used anymore. You can remove the arg 
if not required. Please check and update accordingly.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to