Skip to content

[Mellanox] Updated parse_vpd_data() to use inotify to wait for vpd_data creation#24882

Closed
zili11720 wants to merge 5 commits intosonic-net:masterfrom
zili11720:inotify_vpd_data
Closed

[Mellanox] Updated parse_vpd_data() to use inotify to wait for vpd_data creation#24882
zili11720 wants to merge 5 commits intosonic-net:masterfrom
zili11720:inotify_vpd_data

Conversation

@zili11720
Copy link
Contributor

@zili11720 zili11720 commented Dec 17, 2025

Why I did it

This fixes a race condition where chassis.py attempts to access the VPD data file before it's available during system initialization. When the file doesn't exist yet, _parse_vpd_data() returns an empty dictionary, causing the revision field to be populated with "N/A" in Redis instead of the actual hardware revision value.

Work item tracking
  • Microsoft ADO (number only):

How I did it

Update _parse_vpd_data() to use inotify mechanism to wait for VPD data file creation
before accessing it.

How to verify it

Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@zili11720 zili11720 requested a review from lguohan as a code owner December 17, 2025 15:00
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Zili Bombach <zbombach@nvidia.com>
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@zili11720 zili11720 changed the title Updated parse_vpd_data() to use inotify to wait for vpd_data creation [Mellanox] Updated parse_vpd_data() to use inotify to wait for vpd_data creation Dec 18, 2025

return self.vpd_data.get(REVISION, "N/A")

def _wait_for_file_creation(self, file_path, timeout):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest adding this function to this file, https://github.com/sonic-net/sonic-buildimage/blob/master/platform/mellanox/mlnx-platform-api/sonic_platform/utils.py, it will be convinient to reuse this function in other files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


return self.vpd_data.get(REVISION, "N/A")

def _wait_for_file_creation(self, file_path, timeout):
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible to add some unit tests for the new code?

@zili11720 zili11720 marked this pull request as draft January 22, 2026 10:27
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@zili11720
Copy link
Contributor Author

zili11720 commented Feb 11, 2026

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 24882 in repo sonic-net/sonic-buildimage

Signed-off-by: Zili Bombach <zbombach@nvidia.com>
Signed-off-by: Zili Bombach <zbombach@nvidia.com>
@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@zili11720 zili11720 closed this Mar 4, 2026
@zili11720
Copy link
Contributor Author

This PR is replaced by:
#25879

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants