monitor: Don't create errors for missing sensors
Don't start the error timer (so no errors would be created) in the cases
where the tach sensor is being made nonfunctional because its value
can't be found on D-Bus, as that error indicates a problem with the fan
itself, which is fine.
Also don't check any power off actions in this case either so a running
system isn't turned off.
If no sensors at all are on D-Bus, that is already caught during a power
on.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: If5cd6d1d444be11b9666500db89b4bb82d7b282a
diff --git a/monitor/fan.cpp b/monitor/fan.cpp
index 7bd1542..508d6ac 100644
--- a/monitor/fan.cpp
+++ b/monitor/fan.cpp
@@ -197,13 +197,14 @@
}
catch (const util::DBusServiceError& e)
{
- // The tach property still isn't on D-Bus, ensure
- // sensor is nonfunctional.
+ // The tach property still isn't on D-Bus. Ensure
+ // sensor is nonfunctional, but skip creating an
+ // error for it since it isn't a fan problem.
getLogger().log(fmt::format(
"Monitoring starting but {} sensor value not on D-Bus",
sensor->name()));
- sensor->setFunctional(false);
+ sensor->setFunctional(false, true);
if (_numSensorFailsForNonFunc)
{
@@ -214,7 +215,10 @@
}
}
- _system.fanStatusChange(*this);
+ // At this point, don't start any power off actions due
+ // to missing sensors. Let something else handle that
+ // policy.
+ _system.fanStatusChange(*this, true);
}
}
});
@@ -381,12 +385,16 @@
rangeMax = std::to_string(range.second.value());
}
- sensor.setFunctional(!sensor.functional());
- getLogger().log(
- fmt::format("Setting tach sensor {} functional state to {}. "
- "[target = {}, input = {}, allowed range = ({} - {})]",
- sensor.name(), sensor.functional(), sensor.getTarget(),
- sensor.getInput(), range.first, rangeMax));
+ // Skip starting the error timer if the sensor
+ // isn't on D-Bus as this isn't a fan hardware problem.
+ sensor.setFunctional(!sensor.functional(), !sensor.hasOwner());
+
+ getLogger().log(fmt::format(
+ "Setting tach sensor {} functional state to {}. "
+ "[target = {}, input = {}, allowed range = ({} - {}) "
+ "owned = {}]",
+ sensor.name(), sensor.functional(), sensor.getTarget(),
+ sensor.getInput(), range.first, rangeMax, sensor.hasOwner()));
// A zero value for _numSensorFailsForNonFunc means we aren't dealing
// with fan FRU functional status, only sensor functional status.
@@ -417,7 +425,9 @@
}
}
- _system.fanStatusChange(*this);
+ // Skip the power off rule checks if the sensor isn't
+ // on D-Bus so a running system isn't shutdown.
+ _system.fanStatusChange(*this, !sensor.hasOwner());
}
bool Fan::updateInventory(bool functional)
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index 660a732..ec89d5b 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -238,7 +238,7 @@
}
}
-void TachSensor::setFunctional(bool functional)
+void TachSensor::setFunctional(bool functional, bool skipErrorTimer)
{
_functional = functional;
updateInventory(_functional);
@@ -250,7 +250,7 @@
if (!_functional)
{
- if (_fan.present())
+ if (_fan.present() && !skipErrorTimer)
{
_errorTimer->restartOnce(std::chrono::seconds(*_errorDelay));
}
diff --git a/monitor/tach_sensor.hpp b/monitor/tach_sensor.hpp
index 5b214c4..f3619be 100644
--- a/monitor/tach_sensor.hpp
+++ b/monitor/tach_sensor.hpp
@@ -254,8 +254,12 @@
/**
* Set the functional status and update inventory to match
+ *
+ * @param[in] functional - The new state
+ * @param[in] skipErrorTimer - If setting the sensor to
+ * nonfunctional, don't start the error timer.
*/
- void setFunctional(bool functional);
+ void setFunctional(bool functional, bool skipErrorTimer = false);
/**
* @brief Says if the timer is running or not
@@ -435,7 +439,7 @@
* @brief If functional (not too slow). The parent
* fan object sets this.
*/
- bool _functional;
+ bool _functional = true;
/**
* @brief If the sensor has a Target property (can set speed)