Skip to content

Commit e1fa270

Browse files
authored
vmware: fix volume stats logic (#3473)
During volume stats calculation, if a volume has more than one disk in the chain-info it is not used to sum the physical and virtual size in the loop, instead any previous entry was overwritten by the last disk. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 6a336f8 commit e1fa270

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3612,8 +3612,16 @@ protected GetVolumeStatsAnswer execute(GetVolumeStatsCommand cmd) {
36123612
Pair<VirtualDisk, String> vds = vmMo.getDiskDevice(file.getFileName(), true);
36133613
long virtualsize = vds.first().getCapacityInKB() * 1024;
36143614
long physicalsize = primaryStorageDatastoreMo.fileDiskSize(file.getPath());
3615-
VolumeStatsEntry vse = new VolumeStatsEntry(chainInfo, physicalsize, virtualsize);
3616-
statEntry.put(chainInfo, vse);
3615+
if (statEntry.containsKey(chainInfo)) {
3616+
VolumeStatsEntry vse = statEntry.get(chainInfo);
3617+
if (vse != null) {
3618+
vse.setPhysicalSize(vse.getPhysicalSize() + physicalsize);
3619+
vse.setVirtualSize(vse.getVirtualSize() + virtualsize);
3620+
}
3621+
} else {
3622+
VolumeStatsEntry vse = new VolumeStatsEntry(chainInfo, physicalsize, virtualsize);
3623+
statEntry.put(chainInfo, vse);
3624+
}
36173625
}
36183626
}
36193627
}

0 commit comments

Comments
 (0)