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

worker::CollectionStatus for each inventory FRU #547

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

Conversation

PriyangaRamasamy
Copy link

@PriyangaRamasamy PriyangaRamasamy commented Dec 18, 2024

This commit implements CollectionStatus D-bus property under com.ibm.VPD.Collection D-bus interface for each inventory D-bus object path which represents a FRU.

The property tells the current status of VPD collection for a given FRU's D-bus object path.

The property takes the below enum values:

com.ibm.VPD.Collection.Status.Success
-------------------------------------
This value is assigned when VPD collection is successful.

com.ibm.VPD.Collection.Status.Failure


This value is assigned when we hit prime inventory path on VPD collection failure due to VPD exceptions and also when single FRU VPD collection fails.

com.ibm.VPD.Collection.Status.InProgress


This value is assigned before single FRU VPD collection starts for the given FRU.

com.ibm.VPD.Collection.Status.NotStarted


This value is assigned when we hit prime inventory path when the VPD collection is not started as the FRU itself is not present.

Test:

  1. busctl introspect xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard
    NAME TYPE SIGNATURE RESULT/VALUE FLAGS
    com.ibm.VPD.Collection interface - - -
    .CollectionStatus property s "com.ibm.VPD.Collection.Status.Success" emits-change writable

  2. busctl introspect xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0
    NAME TYPE SIGNATURE RESULT/VALUE FLAGS
    com.ibm.VPD.Collection interface - - -
    .CollectionStatus property s "com.ibm.VPD.Collection.Status.NotSta... emits-change writable

  3. busctl introspect xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson
    NAME TYPE SIGNATURE RESULT/VALUE FLAGS
    com.ibm.VPD.Collection interface - - -
    .CollectionStatus property s "com.ibm.VPD.Collection.Status.Failure" emits-change writable

  4. Previous state is Failure && perform singleFRUVPDCollect busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.Failure"
    root@testhostname2:~busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager CollectFRUVPD o /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson root@testhostname2: busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.Failure"

  5. Previous state is Success && perform singleFRUVPDCollect

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/lcd_op_panel_hill com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.Success"
root@testhostname2:busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager CollectFRUVPD o /xyz/openbmc_project/inventory/system/chassis/motherboard/lcd_op_panel_hill

root@testhostname2:busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/lcd_op_panel_hill com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.Success"

  1. Previous state is NotStarted && perform singleFRUVPDCollect busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0 com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.NotStarted"

root@testhostname2:~ busctl call com.ibm.VPD.Manager /com/ibm/VPD/Manager com.ibm.VPD.Manager CollectFRUVPD o /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0 root@testhostname2:~ busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0 com.ibm.VPD.Collection CollectionStatus s "com.ibm.VPD.Collection.Status.NotStarted"

Change-Id: Ia5010a181f720454bb51538d6fcf308daf6b75ca

Copy link
Collaborator

@SunnySrivastava1984 SunnySrivastava1984 left a comment

Choose a reason for hiding this comment

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

This value is assigned when we hit prime inventory path on
VPD collection failure due to VPD exceptions and also when
single FRU VPD collection fails.

This is not correct.

logging::logMessage("Priming of inventory failed for FRU " +
i_vpdFilePath);
}*/
if (!primeInventory(i_vpdFilePath))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this has been un-commented? This breaks the current flow.

Copy link
Author

Choose a reason for hiding this comment

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

reverted back

if (std::filesystem::exists(i_vpdFilePath))
{
l_propertyValueMap["Present"] = true;

// FRU exist and if we hit prime inventory path
processFRUCollectionStatus(l_interfaces,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't agree with this.
If execution is here, does not mean that the collection has failed.

@@ -1138,6 +1149,10 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
processFunctionalProperty(inventoryPath, interfaces);
processEnabledProperty(inventoryPath, interfaces);

// FRU VPD collection is successful
processFRUCollectionStatus(interfaces,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where do we set the property to "InProgress" in worker class during collection of all the FRUs?

Copy link
Author

Choose a reason for hiding this comment

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

InProgress will not be displayed during collection of all FRUs as its an intermediate state between success/failure. InProgress was introduced for collecting single FRU only.

@@ -1138,6 +1149,10 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
processFunctionalProperty(inventoryPath, interfaces);
processEnabledProperty(inventoryPath, interfaces);

// FRU VPD collection is successful
processFRUCollectionStatus(interfaces,
constants::vpdCollectionSuccess);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also we need to see where can we set it as failure.

@@ -447,6 +448,16 @@ void Manager::collectSingleFruVpd(
}
}

// Set CollectionStatus as InProgress before performing single FRU VPD
// collection
if (!dbusUtility::setFruVpdCollectionStatus(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I dont see a need to persist in-progress status using PIM. It is an intermediate state, no point persisting that data.
Notify is an expensive call compared to set property. If there is no requirement to persist the data, should we use set-property?

Copy link
Author

Choose a reason for hiding this comment

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

done

{
types::PropertyMap l_fruCollectionProperty = {
{"CollectionStatus", i_fruCollectionStatus}};
vpdSpecificUtility::insertOrMerge(io_interfaces,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We already have "insertOrMerge" API in utility. Why this API is required? Just a value is being initialized in the API before "insertOrMerge" is called which could have been directly passed to the API.
Looks more like a wrapper over utility methods with no requirement.

Copy link
Author

Choose a reason for hiding this comment

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

removed this wrapper.

@PriyangaRamasamy
Copy link
Author

Will address all the comments. currently keeping it as draft to avoid further reviews.

@PriyangaRamasamy PriyangaRamasamy marked this pull request as draft December 19, 2024 11:09
@PriyangaRamasamy PriyangaRamasamy marked this pull request as ready for review January 9, 2025 17:50
@PriyangaRamasamy PriyangaRamasamy changed the title Implement CollectionStatus for each inventory FRU worker::CollectionStatus for each inventory FRU Jan 9, 2025
@@ -1103,6 +1111,7 @@ void Worker::populateDbus(const types::VPDMapVariant& parsedVpdMap,
{
const auto& inventoryPath = aFru["inventoryPath"];
sdbusplus::message::object_path fruObjectPath(inventoryPath);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this change?

Copy link
Author

Choose a reason for hiding this comment

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

will remove it

@@ -1469,14 +1506,32 @@ std::tuple<bool, std::string>
logging::logMessage(ex.what());
}

// update CollectionStatus as Failure
types::ObjectMap l_objectMap;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move this to a utility method so that manager can reuse it.

Copy link
Author

Choose a reason for hiding this comment

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

ok

@@ -1375,7 +1392,6 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)

std::shared_ptr<Parser> vpdParser =
std::make_shared<Parser>(i_vpdFilePath, m_parsedJson);

Copy link
Collaborator

Choose a reason for hiding this comment

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

This change?

Copy link
Author

Choose a reason for hiding this comment

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

will remove it

// D-bus set-property call is good enough to update the status.
try
{
const std::string& l_collStatusProp = "CollectionStatus";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why a variable is needed here? Its a one time use variable. Can be used in place?

Copy link
Author

Choose a reason for hiding this comment

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

dbusUtility::writeDbusProperty() expects ref of the property variable. so I need a memory address to be allocated

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's ok, it anyways accepts constant reference.

Copy link
Author

Choose a reason for hiding this comment

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

done

@@ -1421,6 +1437,9 @@ types::VPDMapVariant Worker::parseVpdFile(const std::string& i_vpdFilePath)
std::tuple<bool, std::string>
Worker::parseAndPublishVPD(const std::string& i_vpdFilePath)
{
const std::string& l_inventoryPath =
jsonUtility::getInventoryObjPathFromJson(m_parsedJson, i_vpdFilePath);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This API can throw exceptions and this can go uncaught. This will break the threading for all other collections.

Let the variable be at outer scope, bring the API call to "getInventoryObjPathFromJson" under try/catch.

Copy link
Author

Choose a reason for hiding this comment

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

sure

@PriyangaRamasamy PriyangaRamasamy force-pushed the collectedDbusProperty branch 2 times, most recently from 8040efd to 6956b31 Compare January 17, 2025 10:40
// D-bus set-property call is good enough to update the status.
try
{
const std::string& l_collStatusProp = "CollectionStatus";
Copy link
Collaborator

Choose a reason for hiding this comment

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

That's ok, it anyways accepts constant reference.

*
* @return true if update succeeds, false otherwise.
*/
inline bool notifyFRUCollectionStatus(const std::string& i_inventoryPath,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This API just updates a property on DBus.
Should this be under dbusUtility?

Copy link
Author

Choose a reason for hiding this comment

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

moved it to dbusUtility

This commit implements CollectionStatus D-bus property
under com.ibm.VPD.Collection D-bus interface for each
inventory D-bus object path which represents a FRU.

The property tells the current status of VPD collection
for a given FRU's D-bus object path.

The property takes the below enum values:

>>>com.ibm.VPD.Collection.Status.Success
-------------------------------------
This value is assigned when VPD collection is successful.

>>>com.ibm.VPD.Collection.Status.Failure
-------------------------------------
VPD collection failure due to VPD exceptions.

>>>com.ibm.VPD.Collection.Status.InProgress
----------------------------------------
This value is assigned when VPD collection starts
for the given FRU.

>>>com.ibm.VPD.Collection.Status.NotStarted
----------------------------------------
This default value is assigned when we hit prime inventory path.

Test:
1. VPD parsing failed for /sys/bus/i2c/drivers/at24/0-0051/eeprom due to error: Unable to determine VPD format

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.NotStarted"

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.InProgress"

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/tpm_wilson com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.Failure"

2. FRU not found

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot0/pcie_card0 com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.NotStarted"

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot0/pcie_card0 com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.InProgress"

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot0/pcie_card0 com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.Failure"

3. Successful collection of VPD

busctl get-property xyz.openbmc_project.Inventory.Manager /xyz/openbmc_project/inventory/system/chassis/motherboard com.ibm.VPD.Collection CollectionStatus
s "com.ibm.VPD.Collection.Status.Success"

Change-Id: Ia5010a181f720454bb51538d6fcf308daf6b75ca
Signed-off-by: Priyanga Ramasamy <[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.

2 participants