Damans227 commented on code in PR #14383:
URL: https://github.com/apache/cloudstack/pull/14383#discussion_r4258826043
##########
plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java:
##########
@@ -163,6 +178,16 @@ private static long getCpuSpeedFromCommandLscpu() {
return speed;
}
+ protected static long getCpuMaxSpeedFromCommandLscpu() {
Review Comment:
Script.runSimpleBashScript may return an empty string if lscpu has no CPU
max MHz line. Float.parseFloat("") throws NumberFormatException, which is
caught — but the debug log then prints the empty value. Is there value in
logging this at all if it is only informational? An explicit empty check before
parsing would also avoid the exception.
##########
plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/utils/linux/KVMHostInfo.java:
##########
@@ -163,6 +178,16 @@ private static long getCpuSpeedFromCommandLscpu() {
return speed;
}
+ protected static long getCpuMaxSpeedFromCommandLscpu() {
+ String result = Script.runSimpleBashScript(LSCPU_CPU_MAX_MHZ_COMMAND);
+ try {
+ return (long) Float.parseFloat(result);
+ } catch (NullPointerException | NumberFormatException e) {
+ LOGGER.debug(String.format("Unable to retrieve the CPU max speed
from lscpu; command [%s] resulted in the value [%s].",
LSCPU_CPU_MAX_MHZ_COMMAND, result));
+ return 0L;
+ }
+ }
+
private static long getCpuSpeedFromFile() {
for (final String cpuInfoFreqFileName: cpuInfoFreqFileNames) {
Review Comment:
The catch block logs at DEBUG level while getCpuSpeedFromCommandLscpu() logs
failures at ERROR. If a host genuinely cannot report CPU max MHz, this will be
completely silent in production logs. Is that the right tradeoff — or should at
least the empty-result case (no lscpu line at all) log at INFO to distinguish a
missing lscpu output from a formatting issue?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]