scheduled-host: handle bmc-not-ready error
The BMC Ready feature introduced a new d-bus error when a power on
request is made and the BMC is not at a Ready state.
If someone were to utilize the scheduled transition feature in a way
where they set it to some time in the future, powered their BMC off, and
then powered back on at some later time past the scheduled time, then
the scheduling function will try and start a power on immediately.
This power on would occur prior to the BMC being at Ready, resulting in
the error being returned and the scheduling service failing. Handle the
error during the initialization phase of the service by rescheduling the
operation 60s into the future.
Tested:
- Verified that when BMC was not at Ready state that error was handled
correctly, 60s delay was added on to power on request, and 60s later
it worked successfully.
Change-Id: Ifd97b77e3161667f549e946d843c5f4d0638be74
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/scheduled_host_transition.cpp b/scheduled_host_transition.cpp
index e2361d9..c827807 100644
--- a/scheduled_host_transition.cpp
+++ b/scheduled_host_transition.cpp
@@ -47,6 +47,8 @@
uint64_t ScheduledHostTransition::scheduledTime(uint64_t value)
{
+ info("A scheduled host transtion request has been made for {TIME}", "TIME",
+ value);
if (value == 0)
{
// 0 means the function Scheduled Host Transition is disabled
@@ -93,6 +95,14 @@
{
auto hostPath = std::string{HOST_OBJPATH} + std::to_string(id);
+ auto reqTrans = convertForMessage(HostTransition::scheduledTransition());
+
+ info("Trying to set requestedTransition to {REQUESTED_TRANSITION}",
+ "REQUESTED_TRANSITION", reqTrans);
+
+ utils::setProperty(bus, hostPath, HOST_BUSNAME, PROPERTY_TRANSITION,
+ reqTrans);
+
// Set RestartCause to indicate this transition is occurring due to a
// scheduled host transition as long as it's not an off request
if (HostTransition::scheduledTransition() != HostState::Transition::Off)
@@ -103,13 +113,6 @@
utils::setProperty(bus, hostPath, HOST_BUSNAME, PROPERTY_RESTART_CAUSE,
resCause);
}
- auto reqTrans = convertForMessage(HostTransition::scheduledTransition());
-
- utils::setProperty(bus, hostPath, HOST_BUSNAME, PROPERTY_TRANSITION,
- reqTrans);
-
- info("Set requestedTransition to {REQUESTED_TRANSITION}",
- "REQUESTED_TRANSITION", reqTrans);
}
void ScheduledHostTransition::callback()
@@ -199,7 +202,29 @@
auto deltaTime = seconds(schedTime) - getTime();
if (deltaTime <= seconds(0))
{
- hostTransition();
+ try
+ {
+ hostTransition();
+ }
+ catch (const sdbusplus::exception_t& e)
+ {
+ // If error indicates BMC is not at Ready error then reschedule for
+ // 60s later
+ if ((e.name() != nullptr) &&
+ (e.name() ==
+ std::string_view(
+ "xyz.openbmc_project.State.Host.Error.BMCNotReady")))
+ {
+ warning(
+ "BMC is not at ready, reschedule transition request for 60s");
+ timer.restart(seconds(60));
+ return;
+ }
+ else
+ {
+ throw;
+ }
+ }
// Set scheduledTime to 0 to disable host transition and update
// scheduled values
scheduledTime(0);