From 2bebce6cd4136f39b275a984e1018a1adfb6873b Mon Sep 17 00:00:00 2001 From: Gerorge Liao Date: Tue, 9 Jul 2024 21:47:33 +0200 Subject: [PATCH] [daemon] fix the multipass info after multipass launch failure --- src/daemon/runtime_instance_info_helper.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/daemon/runtime_instance_info_helper.cpp b/src/daemon/runtime_instance_info_helper.cpp index e536b07b00..b690616f38 100644 --- a/src/daemon/runtime_instance_info_helper.cpp +++ b/src/daemon/runtime_instance_info_helper.cpp @@ -94,7 +94,10 @@ void mp::RuntimeInstanceInfoHelper::populate_runtime_info(mp::VirtualMachine& vm info->set_disk_total(results[Keys::disk_total_key].as()); info->set_cpu_count(results[Keys::cpus_key].as()); instance_info->set_cpu_times(results[Keys::cpu_times_key].as()); - instance_info->set_uptime(results[Keys::uptime_key].as()); + // Some older versions Ubuntu might return nothing from "uptime -p" command, which makes the + // results[Keys::uptime_key] null, so IsNull check is necessary here + instance_info->set_uptime(results[Keys::uptime_key].IsNull() ? "0 minutes" + : results[Keys::uptime_key].as()); auto current_release = results[Keys::current_release_key].as(); instance_info->set_current_release(!current_release.empty() ? current_release : original_release);