monitor : do not trigger error when inventory unavailable
Under some startup scenarios, fan-monitor can start before the
InventoryManager service has populated inventory. This leads to
false-positives when marking fans non-functional.
This fix detects D-Bus exceptions and defaults the fans to functional.
They subscribe to the interfaces-added signal which will populate the
fans with correct values as soon as Inventory Manager completes startup.
Signed-off-by: Mike Capps <mikepcapps@gmail.com>
Change-Id: I14bff20da14cba3f5ef4b79763867b5cecab0267
diff --git a/monitor/tach_sensor.cpp b/monitor/tach_sensor.cpp
index cc35c97..daeb1f0 100644
--- a/monitor/tach_sensor.cpp
+++ b/monitor/tach_sensor.cpp
@@ -84,11 +84,13 @@
{
// Query functional state from inventory
// TODO - phosphor-fan-presence/issues/25
- auto service = util::SDBusPlus::getService(
- _bus, util::INVENTORY_PATH + _invName, util::OPERATIONAL_STATUS_INTF);
try
{
+ auto service =
+ util::SDBusPlus::getService(_bus, util::INVENTORY_PATH + _invName,
+ util::OPERATIONAL_STATUS_INTF);
+
if (!service.empty())
{
_functional = util::SDBusPlus::getProperty<bool>(
@@ -100,14 +102,12 @@
// default to functional when service not up. Error handling done
// later
_functional = true;
- updateInventory(_functional);
}
}
catch (util::DBusError& e)
{
log<level::DEBUG>(e.what());
_functional = true;
- updateInventory(_functional);
}
if (!_functional && MethodMode::count == _method)