Skip to content

Commit

Permalink
Merge pull request #3572 from canonical/fix_info_failure_on_old_ubuntu
Browse files Browse the repository at this point in the history
[daemon] fix the multipass info after multipass launch failure
  • Loading branch information
ricab committed Jul 10, 2024
1 parent 92bf2a0 commit 92b8adf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/daemon/runtime_instance_info_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ void mp::RuntimeInstanceInfoHelper::populate_runtime_info(mp::VirtualMachine& vm
info->set_disk_total(results[Keys::disk_total_key].as<std::string>());
info->set_cpu_count(results[Keys::cpus_key].as<std::string>());
instance_info->set_cpu_times(results[Keys::cpu_times_key].as<std::string>());

Check warning on line 96 in src/daemon/runtime_instance_info_helper.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/runtime_instance_info_helper.cpp#L96

Added line #L96 was not covered by tests
instance_info->set_uptime(results[Keys::uptime_key].as<std::string>());
// 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"

Check warning on line 99 in src/daemon/runtime_instance_info_helper.cpp

View check run for this annotation

Codecov / codecov/patch

src/daemon/runtime_instance_info_helper.cpp#L99

Added line #L99 was not covered by tests
: results[Keys::uptime_key].as<std::string>());

auto current_release = results[Keys::current_release_key].as<std::string>();
instance_info->set_current_release(!current_release.empty() ? current_release : original_release);
Expand Down

0 comments on commit 92b8adf

Please sign in to comment.