Make error message more descriptive
Tested:
Verified on a machine with two host nodes.
https://paste.googleplex.com/5628863337725952?raw
Google-Bug-Id: 386135750
Change-Id: I32379a6233fa9277b993f8941b6e702b6f22704e
Signed-off-by: Medicine Yeh <medicineyeh@google.com>
diff --git a/src/dbus_handler.cpp b/src/dbus_handler.cpp
index 2451de7..1e36ca8 100644
--- a/src/dbus_handler.cpp
+++ b/src/dbus_handler.cpp
@@ -52,8 +52,9 @@
if (!isRebooting())
{
fmt::print(stderr,
- "[{}]: Not rebooting. Skip this `rebootComplete` command\n",
- __FUNCTION__);
+ "[dBus Handler] Received `rebootComplete` from '{}' "
+ "while system is not under reboot. Skip.\n",
+ mNodeConfig.node_name);
return;
}
diff --git a/src/psm_handler.cpp b/src/psm_handler.cpp
index de59e09..f19b258 100644
--- a/src/psm_handler.cpp
+++ b/src/psm_handler.cpp
@@ -46,17 +46,18 @@
{
bus.call(method).read(result);
mPreHostState = std::get<std::string>(result);
- fmt::print("[{}] Get `CurrentHostState` success. value={}\n",
- __FUNCTION__, mPreHostState);
+ fmt::print("{} `CurrentHostState` is `{}`\n", mNodeConfig.node_name,
+ mPreHostState);
}
catch (const sdbusplus::exception::SdBusError& e)
{
- fmt::print(stderr, "[{}] Failed to get `CurrentHostState`. ERROR={}\n",
- __FUNCTION__, e.what());
fmt::print(
stderr,
- "[{}] Initialized `mPreHostState` to empty string as default value\n",
- __FUNCTION__);
+ "Failed to query `CurrentHostState` with busctl get-property {} {} "
+ "xyz.openbmc_project.State.Host CurrentHostState"
+ ". Got error: {}\n",
+ psmConfig.hostStateDbusService, psmConfig.hostStateDbusObjPath,
+ e.what());
}
hostStateWatcher = std::make_unique<sdbusplus::bus::match::match>(
@@ -78,8 +79,8 @@
std::get<std::string>(findState->second);
fmt::print(
stderr,
- "[hostStateWatcher] CurrentHostState has changed from {} to {}\n",
- mPreHostState, curHostState);
+ "[hostStateWatcher] {} `CurrentHostState` has changed from {} to {}\n",
+ mNodeConfig.node_name, mPreHostState, curHostState);
absl::Status status = mApi->SetNodeCheckpoint(
mNodeConfig, translateHostStateName(curHostState), 0, 0);
btm::log::LogIfError(status);
@@ -99,18 +100,18 @@
{
bus.call(method).read(result);
mPreOSState = std::get<std::string>(result);
- fmt::print("[{}] Get `OperatingSystemState` success. value={}\n",
- __FUNCTION__, mPreOSState);
+ fmt::print("{} `OperatingSystemState` is `{}`\n", mNodeConfig.node_name,
+ mPreOSState);
}
catch (const sdbusplus::exception::SdBusError& e)
{
- fmt::print(stderr,
- "[{}] Failed to get `OperatingSystemState`. ERROR={}\n",
- __FUNCTION__, e.what());
fmt::print(
stderr,
- "[{}] Initialized `mPreOSState` to empty string as default value\n",
- __FUNCTION__);
+ "Failed to query OperatingSystemState with busctl get-property {} {} "
+ "xyz.openbmc_project.State.OperatingSystem.Status OperatingSystemState."
+ "Got error: {}\n",
+ psmConfig.hostStateDbusService, psmConfig.hostStateDbusObjPath,
+ e.what());
}
osStatusWatcher = std::make_unique<sdbusplus::bus::match::match>(
@@ -134,8 +135,8 @@
fmt::print(
stderr,
- "[osStatusWatcher] curOSStatus has changed from {} to {}\n",
- mPreOSState, curOSStatus);
+ "[osStatusWatcher] {} `OperatingSystemState` has changed from {} to {}\n",
+ mNodeConfig.node_name, mPreOSState, curOSStatus);
absl::Status status = mApi->SetNodeCheckpoint(
mNodeConfig, translateOSStatus(curOSStatus), 0, 0);
btm::log::LogIfError(status);
diff --git a/src/systemd_handler.cpp b/src/systemd_handler.cpp
index aca8ec5..ccf5f53 100644
--- a/src/systemd_handler.cpp
+++ b/src/systemd_handler.cpp
@@ -116,22 +116,22 @@
// If the system is booted, ensure any pending reboot state is cleared.
if (mApi->IsNodeRebooting(mNode))
{
- fmt::print(
- stderr,
- "System already booted; marking reboot as complete for '{}'\n",
- mNode.node_name);
+ fmt::print(stderr,
+ "'{}' is already booted; marking reboot as complete.\n",
+ mNode.node_name);
btm::log::LogIfError(mApi->NotifyNodeComplete(mNode));
}
else
{
- fmt::print(stderr, "System already booted. No action needed.\n");
+ fmt::print(stderr, "'{}' is already booted.\n", mNode.node_name);
}
return;
}
// If not booted, start polling for boot completion.
- fmt::print(stderr,
- "System not yet booted. Waiting for systemd to finish...\n");
+ fmt::print(
+ stderr,
+ "BMC is not yet fully booted. Waiting for systemd to finish...\n");
mBMCFinishTimer.expires_at(std::chrono::steady_clock::now());
mBMCFinishTimer.async_wait(
[this](const auto& ec) { UpdateBmcCheckpoints(ec); });