mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Merge pull request #1182 from ustcweizhou/CLOUDSTACK-9113-getVmStats
[4.6] CLOUDSTACK-9113: skip vm with inconsistent state when getVmStats/getVmDiskStatson KVM, if there is a vm has inconsistent state between hypervisor and db, the getVmStat will terminate and return null, all vm stats will not be updated. we should skip the vm which has inconsistent state, and continue on others. * pr/1182: CLOUDSTACK-9113: skip vm with inconsistent state when getVmStats/getVmDiskStats Signed-off-by: Remi Bergsma <github@remi.nl>
This commit is contained in:
commit
65bf2edfa1
@ -48,12 +48,16 @@ public final class LibvirtGetVmDiskStatsCommandWrapper extends CommandWrapper<Ge
|
||||
final HashMap<String, List<VmDiskStatsEntry>> vmDiskStatsNameMap = new HashMap<String, List<VmDiskStatsEntry>>();
|
||||
final Connect conn = libvirtUtilitiesHelper.getConnection();
|
||||
for (final String vmName : vmNames) {
|
||||
final List<VmDiskStatsEntry> statEntry = libvirtComputingResource.getVmDiskStat(conn, vmName);
|
||||
if (statEntry == null) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
final List<VmDiskStatsEntry> statEntry = libvirtComputingResource.getVmDiskStat(conn, vmName);
|
||||
if (statEntry == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
vmDiskStatsNameMap.put(vmName, statEntry);
|
||||
vmDiskStatsNameMap.put(vmName, statEntry);
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.warn("Can't get vm disk stats: " + e.toString() + ", continue");
|
||||
}
|
||||
}
|
||||
return new GetVmDiskStatsAnswer(command, "", command.getHostName(), vmDiskStatsNameMap);
|
||||
} catch (final LibvirtException e) {
|
||||
@ -61,4 +65,4 @@ public final class LibvirtGetVmDiskStatsCommandWrapper extends CommandWrapper<Ge
|
||||
return new GetVmDiskStatsAnswer(command, null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,12 +49,16 @@ public final class LibvirtGetVmStatsCommandWrapper extends CommandWrapper<GetVmS
|
||||
final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper();
|
||||
|
||||
final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(vmName);
|
||||
final VmStatsEntry statEntry = libvirtComputingResource.getVmStat(conn, vmName);
|
||||
if (statEntry == null) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
final VmStatsEntry statEntry = libvirtComputingResource.getVmStat(conn, vmName);
|
||||
if (statEntry == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
vmStatsNameMap.put(vmName, statEntry);
|
||||
vmStatsNameMap.put(vmName, statEntry);
|
||||
} catch (LibvirtException e) {
|
||||
s_logger.warn("Can't get vm stats: " + e.toString() + ", continue");
|
||||
}
|
||||
}
|
||||
return new GetVmStatsAnswer(command, vmStatsNameMap);
|
||||
} catch (final LibvirtException e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user