From aebfde81481ee93d78ade02803b931b2bd1e4419 Mon Sep 17 00:00:00 2001 From: Dhruvaraj Subhashchandran Date: Tue, 11 Jul 2017 01:36:33 -0500 Subject: Fix for mapper errors during logging service restart There was a race condition while calling mapper from led monitoring after error logs started persisting, to avoid such errors the callout information is now extracted from the message received as part of interface added signal. Resolves openbmc/openbmc#1853 Change-Id: Ie913992bdcb3b1cb93677d64331db34202f8ae72 Signed-off-by: Dhruvaraj Subhashchandran --- elog-errors.hpp | 88 ----------------------- fault-monitor/fru-fault-monitor.cpp | 55 +++++--------- xyz/openbmc_project/Led/Fru/Monitor.errors.yaml | 4 -- xyz/openbmc_project/Led/Fru/Monitor.metadata.yaml | 5 -- 4 files changed, 19 insertions(+), 133 deletions(-) diff --git a/elog-errors.hpp b/elog-errors.hpp index 1cc6f4a..95c80e7 100644 --- a/elog-errors.hpp +++ b/elog-errors.hpp @@ -9,28 +9,6 @@ #include #include -namespace sdbusplus -{ -namespace xyz -{ -namespace openbmc_project -{ -namespace Led -{ -namespace Fru -{ -namespace Monitor -{ -namespace Error -{ - struct AssociationRetrieveError; -} // namespace Error -} // namespace Monitor -} // namespace Fru -} // namespace Led -} // namespace openbmc_project -} // namespace xyz -} // namespace sdbusplus namespace sdbusplus { @@ -168,72 +146,6 @@ struct map_exception_type,const char*>; - explicit constexpr ELOG_ENTRY_PATH(const char* a) : _entry(entry(str, a)) {}; - type _entry; -}; - -} // namespace _AssociationRetrieveError - -struct AssociationRetrieveError : public sdbusplus::exception_t -{ - static constexpr auto errName = "xyz.openbmc_project.Led.Fru.Monitor.AssociationRetrieveError"; - static constexpr auto errDesc = "Error in retrieving the associations from elog entry."; - static constexpr auto L = level::INFO; - using ELOG_ENTRY_PATH = _AssociationRetrieveError::ELOG_ENTRY_PATH; - using metadata_types = std::tuple; - - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } -}; - -} // namespace Monitor -} // namespace Fru -} // namespace Led -} // namespace openbmc_project -} // namespace xyz - - -namespace details -{ - -template <> -struct map_exception_type -{ - using type = xyz::openbmc_project::Led::Fru::Monitor::AssociationRetrieveError; -}; - -} - namespace xyz { namespace openbmc_project diff --git a/fault-monitor/fru-fault-monitor.cpp b/fault-monitor/fru-fault-monitor.cpp index 8bf27f2..dc2f231 100644 --- a/fault-monitor/fru-fault-monitor.cpp +++ b/fault-monitor/fru-fault-monitor.cpp @@ -26,13 +26,17 @@ constexpr auto LOG_PATH = "/xyz/openbmc_project/logging"; using AssociationList = std::vector>; +using Attributes = sdbusplus::message::variant; +using AttributeName = std::string; +using AttributeMap = std::map; +using PropertyName = std::string; +using PropertyMap = std::map; +using LogEntryMsg = std::pair; + using MethodErr = sdbusplus::xyz::openbmc_project::Led::Mapper::Error::MethodError; using ObjectNotFoundErr = sdbusplus::xyz::openbmc_project::Led::Mapper::Error::ObjectNotFoundError; -using AssociationRetrieveErr = - sdbusplus::xyz::openbmc_project:: - Led::Fru::Monitor::Error::AssociationRetrieveError; using InventoryPathErr = sdbusplus::xyz::openbmc_project:: Led::Fru::Monitor::Error::InventoryPathError; @@ -121,9 +125,9 @@ void Add::created(sdbusplus::message::message& msg) { auto bus = msg.get_bus(); - sdbusplus::message::object_path obPath; - msg.read(obPath); - std::string objectPath(std::move(obPath)); + LogEntryMsg logEntry; + msg.read(logEntry); + std::string objectPath(std::move(logEntry.first)); std::size_t found = objectPath.find(ELOG_ENTRY); if (found == std::string::npos) @@ -131,44 +135,22 @@ void Add::created(sdbusplus::message::message& msg) //Not a new error entry skip return; } + log(objectPath.c_str()); - std::string service; - try - { - service = getService(bus, LOG_PATH); - } - catch (MethodErr& e) - { - commit(); - return; - } - catch (ObjectNotFoundErr& e) + auto iter = logEntry.second.find("org.openbmc.Associations"); + if (iter == logEntry.second.end()) { - commit(); return; } - auto method = bus.new_method_call(service.c_str(), objectPath.c_str(), - "org.freedesktop.DBus.Properties", - "Get"); - - method.append("org.openbmc.Associations"); - method.append("associations"); - auto reply = bus.call(method); - if (reply.is_method_error()) + auto attr = iter->second.find("associations"); + if (attr == iter->second.end()) { - using namespace xyz::openbmc_project::Led::Fru::Monitor; - report( - AssociationRetrieveError::ELOG_ENTRY_PATH( - objectPath.c_str())); return; } - sdbusplus::message::variant assoc; - reply.read(assoc); - - auto assocs = - sdbusplus::message::variant_ns::get(assoc); + auto& assocs = + sdbusplus::message::variant_ns::get(attr->second); if (assocs.empty()) { //No associations skip @@ -181,9 +163,10 @@ void Add::created(sdbusplus::message::message& msg) { action(bus, std::get<2>(item), true); removeWatches.emplace_back( - std::make_unique(bus, std::get<2>(item))); + std::make_unique(bus, std::get<2>(item))); } } + return; } diff --git a/xyz/openbmc_project/Led/Fru/Monitor.errors.yaml b/xyz/openbmc_project/Led/Fru/Monitor.errors.yaml index bb77f45..e949513 100644 --- a/xyz/openbmc_project/Led/Fru/Monitor.errors.yaml +++ b/xyz/openbmc_project/Led/Fru/Monitor.errors.yaml @@ -1,7 +1,3 @@ #xyz.openbmc_project.Led.Fru.Monitor.InventoryPathError - name: InventoryPathError description: Invalid Inventory Path. - -#xyz.openbmc_project.Led.Fru.Monitor.AssociationRetrieveError -- name: AssociationRetrieveError - description: Error in retrieving the associations from elog entry. diff --git a/xyz/openbmc_project/Led/Fru/Monitor.metadata.yaml b/xyz/openbmc_project/Led/Fru/Monitor.metadata.yaml index bd59e5f..57e0fd5 100644 --- a/xyz/openbmc_project/Led/Fru/Monitor.metadata.yaml +++ b/xyz/openbmc_project/Led/Fru/Monitor.metadata.yaml @@ -2,8 +2,3 @@ meta: - str: "PATH=%s" type: string - -- name: AssociationRetrieveError - meta: - - str: "ELOG_ENTRY_PATH=%s" - type: string -- cgit v1.2.1