Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute Post Fail Action if VPD parsing fails #425

Open
wants to merge 1 commit into
base: P11_Dev
Choose a base branch
from

Conversation

souvik1914581
Copy link

This commit adds changes to execute Post Fail Action for a FRU if Pre Action for the FRU has passed and VPD parsing has failed.

Test:

  1. Create a malformed VPD file by modifying copy of 7-0051/eeprom, name the copy as 7-0051_eeprom_noVTOC.dat
  2. Create a copy of 50001001.json, name the copy as 50001001_custom.json. Replace "/sys/bus/i2c/drivers/at24/7-0051/eeprom" string in the custom JSON with "7-0051_eeprom_noVTOC.dat".
  3. Run ./vpd-parser -f /tmp/7-0051_eeprom_noVTOC.dat -c ./50001001_custom.json.
  4. Observe the logs to see "preAction" is successful, VPD parsing fails and "postFailAction" is executed as specified in the custom JSON.
  5. Now run /vpd-parser -f /sys/bus/i2c/drivers/at24/7-0051/eeprom -c ./50001001.json.
  6. Observe the logs to see "preAction" is successful, VPD parsing is successful and "postFailAction" is not executed.

souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Oct 16, 2024
This commit adds changes to execute Post Fail Action for a FRU if
Pre Action for the FRU has passed and VPD parsing has failed.

Test:
1. Create a malformed VPD file by modifying copy of 7-0051/eeprom,
   name the copy as 7-0051_eeprom_noVTOC.dat
2. Create a copy of 50001001.json, name the copy as
   50001001_custom.json.
   Replace "/sys/bus/i2c/drivers/at24/7-0051/eeprom" string in the custom
   JSON with "7-0051_eeprom_noVTOC.dat".
3. Run ./vpd-parser -f /tmp/7-0051_eeprom_noVTOC.dat -c
   ./50001001_custom.json.
4. Observe the logs to see "preAction" is successful, VPD parsing fails
   and "postFailAction" is executed as specified in the custom JSON.
5. Now run /vpd-parser -f /sys/bus/i2c/drivers/at24/7-0051/eeprom
   -c ./50001001.json.
6. Observe the logs to see "preAction" is successful, VPD parsing is
   successful and "postFailAction" is not executed.

Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Oct 16, 2024
This commit adds changes to execute Post Fail Action for a FRU if
Pre Action for the FRU has passed and VPD parsing has failed.

Test:
1. Create a malformed VPD file by modifying copy of 7-0051/eeprom,
   name the copy as 7-0051_eeprom_noVTOC.dat
2. Create a copy of 50001001.json, name the copy as
   50001001_custom.json.
   Replace "/sys/bus/i2c/drivers/at24/7-0051/eeprom" string in the custom
   JSON with "7-0051_eeprom_noVTOC.dat".
3. Run ./vpd-parser -f /tmp/7-0051_eeprom_noVTOC.dat -c
   ./50001001_custom.json.
4. Observe the logs to see "preAction" is successful, VPD parsing fails
   and "postFailAction" is executed as specified in the custom JSON.
5. Now run /vpd-parser -f /sys/bus/i2c/drivers/at24/7-0051/eeprom
   -c ./50001001.json.
6. Observe the logs to see "preAction" is successful, VPD parsing is
   successful and "postFailAction" is not executed.

Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Oct 16, 2024
This commit adds changes to execute Post Fail Action for a FRU if
Pre Action for the FRU has passed and VPD parsing has failed.

Test:
1. Create a malformed VPD file by modifying copy of 7-0051/eeprom,
   name the copy as 7-0051_eeprom_noVTOC.dat
2. Create a copy of 50001001.json, name the copy as
   50001001_custom.json.
   Replace "/sys/bus/i2c/drivers/at24/7-0051/eeprom" string in the custom
   JSON with "7-0051_eeprom_noVTOC.dat".
3. Run ./vpd-parser -f /tmp/7-0051_eeprom_noVTOC.dat -c
   ./50001001_custom.json.
4. Observe the logs to see "preAction" is successful, VPD parsing fails
   and "postFailAction" is executed as specified in the custom JSON.
5. Now run /vpd-parser -f /sys/bus/i2c/drivers/at24/7-0051/eeprom
   -c ./50001001.json.
6. Observe the logs to see "preAction" is successful, VPD parsing is
   successful and "postFailAction" is not executed.

Signed-off-by: Souvik Roy <[email protected]>
souvik1914581 pushed a commit to souvik1914581/openpower-vpd-parser that referenced this pull request Oct 16, 2024
This commit adds changes to execute Post Fail Action for a FRU if
Pre Action for the FRU has passed and VPD parsing has failed.

Test:
1. Create a malformed VPD file by modifying copy of 7-0051/eeprom,
   name the copy as 7-0051_eeprom_noVTOC.dat
2. Create a copy of 50001001.json, name the copy as
   50001001_custom.json.
   Replace "/sys/bus/i2c/drivers/at24/7-0051/eeprom" string in the custom
   JSON with "7-0051_eeprom_noVTOC.dat".
3. Run ./vpd-parser -f /tmp/7-0051_eeprom_noVTOC.dat -c
   ./50001001_custom.json.
4. Observe the logs to see "preAction" is successful, VPD parsing fails
   and "postFailAction" is executed as specified in the custom JSON.
5. Now run /vpd-parser -f /sys/bus/i2c/drivers/at24/7-0051/eeprom
   -c ./50001001.json.
6. Observe the logs to see "preAction" is successful, VPD parsing is
   successful and "postFailAction" is not executed.
7. Create a copy of 50001001_custom.json
   50001001_custom_noPostFail.json with "PostFailAction" tag deleted.
8. Run ./vpd-parser -f /tmp/7-0051_eeprom_noVTOC.dat -c
   50001001_custom_noPostFail.json
9. Observe the logs to see "preAction" is successful, VPD parsing fails
   and "postFailAction" also fails.

Signed-off-by: Souvik Roy <[email protected]>
// after collection for FRU is successfully done.
if (jsonUtility::isActionRequired(m_parsedJson, i_vpdFilePath, "postAction",
"collection"))
try

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we extend try block for Parser object creation as well ? so we can run "executePostFailAction" .
As we are introducing throwing an exception in Parser constructor.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parser constructor does not throw any exception right now. Are we planning to add any throw in the Parser constructor later?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#380
raising exception in case of error paths.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@branupama That can be extended once we introduce that change in parser class.

{
throw std::runtime_error(
"Required post action failed for path " + i_vpdFilePath +
" Aborting collection for this FRU");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we are aborting the collection if "postAction" fails ?
why we are not populating the collected VPD ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't change this logic. I just moved it under try block.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@branupama Why do you think that a FRU should be populated if there is a processing failure at any stage?

src/worker.cpp Outdated
}
catch (std::exception& ex)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l_exception ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not using l_ for the exception object reference throughout worker.cpp, so to maintain consistency, I followed the same convention.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@souvik1914581 The code of worker was written before we brought it the guidelines. Hennce, with new addition we are following that.
Please modify with l_ex.

src/worker.cpp Outdated
{
throw std::runtime_error("Post fail action failed for path " +
i_vpdFilePath +
" Aborting collection for this FRU");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we are not aborting anything, is the message should be ?
"VPD collection failed for the FRU " + i_vpdFilePath

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We end up in this catch block if

  1. vpdParser->parse() throws when parsing fails.
  2. processPostAction() throws if parsedVpd has no value.

Do you mean we should check for the type of exception caught and log accordingly here?
On a side note: I just noticed processPostAction() throws but it's doxygen doesn't mention @throws.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, this is fine.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@souvik1914581 In the case that you have added, in case "executePostFailAction" also fails then we loose the exception that was thrown by the parser path.
Could you please add that log as well to the log that you have added so that we don't miss the reason, why collection failed.

// after collection for FRU is successfully done.
if (jsonUtility::isActionRequired(m_parsedJson, i_vpdFilePath, "postAction",
"collection"))
try

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#380
raising exception in case of error paths.

src/worker.cpp Outdated
{
throw std::runtime_error("Post fail action failed for path " +
i_vpdFilePath +
" Aborting collection for this FRU");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, this is fine.

// after collection for FRU is successfully done.
if (jsonUtility::isActionRequired(m_parsedJson, i_vpdFilePath, "postAction",
"collection"))
try
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@branupama That can be extended once we introduce that change in parser class.

{
throw std::runtime_error(
"Required post action failed for path " + i_vpdFilePath +
" Aborting collection for this FRU");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@branupama Why do you think that a FRU should be populated if there is a processing failure at any stage?

src/worker.cpp Outdated
}
catch (std::exception& ex)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@souvik1914581 The code of worker was written before we brought it the guidelines. Hennce, with new addition we are following that.
Please modify with l_ex.

src/worker.cpp Outdated
{
throw std::runtime_error("Post fail action failed for path " +
i_vpdFilePath +
" Aborting collection for this FRU");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@souvik1914581 In the case that you have added, in case "executePostFailAction" also fails then we loose the exception that was thrown by the parser path.
Could you please add that log as well to the log that you have added so that we don't miss the reason, why collection failed.

This commit adds changes to execute Post Fail Action for a FRU if
Pre Action for the FRU has passed and VPD parsing has failed.

Test:
1. Create a malformed VPD file by modifying copy of 7-0051/eeprom,
   name the copy as 7-0051_eeprom_noVTOC.dat
2. Create a copy of 50001001.json, name the copy as
   50001001_custom.json.
   Replace "/sys/bus/i2c/drivers/at24/7-0051/eeprom" string in the custom
   JSON with "7-0051_eeprom_noVTOC.dat".
3. Run ./vpd-parser -f /tmp/7-0051_eeprom_noVTOC.dat -c
   ./50001001_custom.json.
4. Observe the logs to see "preAction" is successful, VPD parsing fails
   and "postFailAction" is executed as specified in the custom JSON.
5. Now run /vpd-parser -f /sys/bus/i2c/drivers/at24/7-0051/eeprom
   -c ./50001001.json.
6. Observe the logs to see "preAction" is successful, VPD parsing is
   successful and "postFailAction" is not executed.
7. Create a copy of 50001001_custom.json
   50001001_custom_noPostFail.json with "PostFailAction" tag deleted.
8. Run ./vpd-parser -f /tmp/7-0051_eeprom_noVTOC.dat -c
   50001001_custom_noPostFail.json
9. Observe the logs to see "preAction" is successful, VPD parsing fails
   and "postFailAction" also fails.

Signed-off-by: Souvik Roy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants