Skip to content

[Mellanox] Fix BMC import issue#27721

Open
stephenxs wants to merge 2 commits into
sonic-net:masterfrom
stephenxs:upstream-fix-bmc-import
Open

[Mellanox] Fix BMC import issue#27721
stephenxs wants to merge 2 commits into
sonic-net:masterfrom
stephenxs:upstream-fix-bmc-import

Conversation

@stephenxs

Copy link
Copy Markdown
Collaborator

Why I did it

After lazy BMC initialization (#26901), from .bmc import BMC lived only inside initialize_components(). initialize_bmc() still calls BMC.get_instance() in the chassis module scope, so BMC was never defined there. That breaks BMC CLIs on OpenBMC platforms, for example:

  • sudo show platform bmc summaryError retrieving BMC information: name 'BMC' is not defined
  • sudo show platform bmc eepromError retrieving BMC EEPROM information: name 'BMC' is not defined

The import must run in the function that uses BMC, while keeping lazy load so non-BMC platforms do not pull in BMC/Redfish at chassis import time.

Work item tracking
  • Microsoft ADO (number only):

How I did it

  • Moved from .bmc import BMC from initialize_components() into initialize_bmc() in platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py.
  • Left the DeviceDataManager.is_platform_with_bmc() gate in initialize_components() unchanged; only the import site moved.
  • Lazy-load behavior is unchanged: bmc.py is still loaded only when BMC initialization runs on BMC-capable platforms.

How to verify it

  1. Unit tests (from repo root):
    cd platform/mellanox/mlnx-platform-api
    pytest tests/test_chassis.py tests/test_bmc.py -v

2. **On a BMC-capable DUT** (e.g. SN6600 LD with bmc.json present):

```bash
sudo show platform bmc summary
sudo show platform bmc eeprom

Expect BMC fields (manufacturer, model, serial, etc.), not name 'BMC' is not defined.

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)

Signed-off-by: Stephen Sun <stephens@nvidia.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Stephen Sun <stephens@nvidia.com>
@stephenxs stephenxs marked this pull request as ready for review June 4, 2026 10:38
@stephenxs stephenxs requested a review from lguohan as a code owner June 4, 2026 10:38
@stephenxs stephenxs requested review from benle7 and keboliu June 4, 2026 10:41
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@stephenxs stephenxs changed the title Fix BMC import issue [Mellanox] Fix BMC import issue Jun 4, 2026
@stephenxs

Copy link
Copy Markdown
Collaborator Author

/azpw run

@mssonicbld

Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1130678:

✅Stage Build:

  • Job marvell_prestera_armhf: retried.

@stephenxs stephenxs requested a review from gpunathilell June 5, 2026 00:11

@benle7 benle7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

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.

4 participants