Skip to content

Commit

Permalink
Handle PostFailAction tag
Browse files Browse the repository at this point in the history
VPD collection for the FRU’s which doesn’t has PostFailAction tag in
the system config JSON is failing with ‘Pre-Action failed’ log even
though pre action passed for that FRU.

This commit handles the above issue, post fail action will be triggered
in case of pre action fails or the VPD parsing for the EEPROM itself
fails, in case ‘PostFailAction’ tag found in the system config JSON.

Signed-off-by: Anupama B R <[email protected]>
  • Loading branch information
branupama authored and jinuthomas committed Nov 8, 2024
1 parent c01bbcb commit 473a957
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 54 deletions.
16 changes: 0 additions & 16 deletions include/utility/json_utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,6 @@ inline bool executePostFailAction(const nlohmann::json& i_parsedConfigJson,
return false;
}

if (!(i_parsedConfigJson["frus"][i_vpdFilePath].at(0).contains(
"PostFailAction")))
{
logging::logMessage(
"PostFailAction flag missing in config JSON. Abort processing");

return false;
}

if (!(i_parsedConfigJson["frus"][i_vpdFilePath].at(0))["PostFailAction"]
.contains(i_flagToProcess))
{
Expand Down Expand Up @@ -455,13 +446,6 @@ inline bool procesSetGpioTag(const nlohmann::json& i_parsedConfigJson,
l_errMsg += ex.what();
l_errMsg += " File: " + i_vpdFilePath + " Pel Logged";

// Take failure postAction
if (!executePostFailAction(i_parsedConfigJson, i_vpdFilePath,
i_flagToProcess))
{
logging::logMessage("executePostFailAction failed from exception.");
}

// ToDo -- Update Internal RC code
EventLogger::createAsyncPelWithInventoryCallout(
types::ErrorType::GpioError, types::SeverityType::Warning,
Expand Down
54 changes: 16 additions & 38 deletions src/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,50 +1159,27 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)
"Empty VPD file path passed to Worker::parseVpdFile. Abort processing");
}

bool l_isPostFailActionRequired = false;

// check if the FRU qualifies for pre action.
if (jsonUtility::isActionRequired(m_parsedJson, i_vpdFilePath, "preAction",
"collection"))
try
{
// post fail action is required for a FRU if pre action is successful
// and some post fail action is defined for the FRU in the System Config
// JSON.
if (processPreAction(i_vpdFilePath, "collection") &&
jsonUtility::isActionRequired(m_parsedJson, i_vpdFilePath,
"PostFailAction", "collection"))
{
l_isPostFailActionRequired = true;
}
else
if (jsonUtility::isActionRequired(m_parsedJson, i_vpdFilePath,
"preAction", "collection"))
{
throw std::runtime_error("Pre-Action failed for path " +
i_vpdFilePath +
" Aborting collection for this FRU");
if (!processPreAction(i_vpdFilePath, "collection"))
{
throw std::runtime_error("Pre-Action failed");
}
}
}

if (!std::filesystem::exists(i_vpdFilePath))
{
if (l_isPostFailActionRequired)
if (!std::filesystem::exists(i_vpdFilePath))
{
if (!jsonUtility::executePostFailAction(m_parsedJson, i_vpdFilePath,
"collection"))
{
throw std::runtime_error("Post fail action failed for path " +
i_vpdFilePath +
" Aborting collection for this FRU");
}
throw std::runtime_error("Could not find file path " +
i_vpdFilePath +
"Skipping parser trigger for the EEPROM");
}

throw std::runtime_error("Could not find file path " + i_vpdFilePath +
"Skipping parser trigger for the EEPROM");
}
std::shared_ptr<Parser> vpdParser =
std::make_shared<Parser>(i_vpdFilePath, m_parsedJson);

std::shared_ptr<Parser> vpdParser = std::make_shared<Parser>(i_vpdFilePath,
m_parsedJson);
try
{
types::VPDMapVariant l_parsedVpd = vpdParser->parse();

// Before returning, as collection is over, check if FRU qualifies for
Expand All @@ -1224,8 +1201,9 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)
}
catch (std::exception& l_ex)
{
// If VPD parsing fails, and post fail action is required, execute it.
if (l_isPostFailActionRequired)
// If post fail action is required, execute it.
if (jsonUtility::isActionRequired(m_parsedJson, i_vpdFilePath,
"PostFailAction", "collection"))
{
if (!jsonUtility::executePostFailAction(m_parsedJson, i_vpdFilePath,
"collection"))
Expand Down

0 comments on commit 473a957

Please sign in to comment.