Skip to content

fix(bmc-mock): better support of BF4 Nvidia OEM endpoint#3072

Merged
poroh merged 1 commit into
NVIDIA:mainfrom
poroh:bmc-mock-bf4-nvidia-oem
Jul 2, 2026
Merged

fix(bmc-mock): better support of BF4 Nvidia OEM endpoint#3072
poroh merged 1 commit into
NVIDIA:mainfrom
poroh:bmc-mock-bf4-nvidia-oem

Conversation

@poroh

@poroh poroh commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

BF4 doesn't provide BaseMac and NicMode attributes in its /redfish/v1/Systems/Bluefield/Oem/Nvidia path.

Related issues

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Additional Notes

@copy-pr-bot

copy-pr-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • New Features
    • Enhanced hardware-specific Redfish OEM state selection for different BlueField devices.
  • Bug Fixes
    • Refined BlueField 3 NIC mode staging/apply behavior to only apply where supported.
    • Adjusted BlueField 4 Redfish responses to omit unsupported mode and MAC details.
  • Tests
    • Removed a BlueField 4 site-explorer integration regression test related to host/DPU pairing behavior.

Walkthrough

BluefieldState now models BF3 and BF4 as separate variants, with constructors and mode handling split accordingly. OEM state generation is delegated through DpuMachineInfo, and the site-explorer BF4 regression test was removed.

Changes

BlueField OEM state refactor

Layer / File(s) Summary
BluefieldState enum and constructors
crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs
BluefieldState becomes an enum with Bluefield3 and Bluefield4 variants, and the BF-3/BF-4 constructors are split into new_bf3 and new_bf4.
Mode handling and Redfish read-back per variant
crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs
Variant-specific mode access and pending-mode application are implemented, get_oem_nvidia branches on the BluefieldState variant, and the BF-3 staging test uses the new constructor.
DpuMachineInfo and MachineInfo delegation
crates/bmc-mock/src/machine_info.rs
DpuMachineInfo::oem_state() selects BF-3 or BF-4 OEM state from dpu_type(), and MachineInfo::oem_state() delegates the DPU branch to that method.

Site explorer BF4 regression removal

Layer / File(s) Summary
BF4 integration test deletion
crates/site-explorer/tests/integration/site_explorer.rs
The BF4 pairing regression test and its supporting imports are removed from the integration suite.

Estimated code review effort: 2 (Simple) | ~15 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the BF4 Nvidia OEM endpoint fix in bmc-mock.
Description check ✅ Passed The description is directly related to the BF4 BaseMac/NicMode behavior change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@poroh poroh marked this pull request as ready for review July 1, 2026 20:07
@poroh poroh requested a review from a team as a code owner July 1, 2026 20:07

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs (1)

200-203: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a BF4 regression case for the changed endpoint contract.

The updated test still only exercises BF3 staging. Add a BF4 case verifying /Oem/Nvidia omits Mode/BaseMAC and covers the chosen Mode.Set behavior for BF4. Prefer table-driven coverage if setup is shared.

As per coding guidelines, verification should exercise the behavior that changed and Rust tests should prefer table-driven style.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs` around lines 200 - 203,
The current test coverage in BluefieldState only exercises BF3 staging, so add a
BF4 regression case for the changed /Oem/Nvidia contract. Update the existing
mode-setting coverage around mode_set_is_staged_and_applied_on_power_on, or
factor shared setup into a table-driven test, to verify that BF4 omits Mode and
BaseMAC from the OEM payload and that the chosen Mode.Set behavior is exercised
for BF4. Keep the shared assertions in BluefieldState-related tests so both BF3
and BF4 behavior are covered clearly.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs`:
- Around line 64-79: Bluefield4 mode handling currently treats unsupported
operations as a successful no-op by returning false from nic_mode() and
accepting stage_mode() without error. Update the Bluefield enum handling so
Bluefield3 and Bluefield4 are distinguished in nic_mode() and stage_mode(), and
make Bluefield4 return an unsupported/error result for Mode.Set instead of
silently mapping absence of state to false; if needed, change the API to surface
Option<bool> so callers can tell “no mode” apart from DPU mode.

---

Nitpick comments:
In `@crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs`:
- Around line 200-203: The current test coverage in BluefieldState only
exercises BF3 staging, so add a BF4 regression case for the changed /Oem/Nvidia
contract. Update the existing mode-setting coverage around
mode_set_is_staged_and_applied_on_power_on, or factor shared setup into a
table-driven test, to verify that BF4 omits Mode and BaseMAC from the OEM
payload and that the chosen Mode.Set behavior is exercised for BF4. Keep the
shared assertions in BluefieldState-related tests so both BF3 and BF4 behavior
are covered clearly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8f3f5de2-7402-4cf8-8a18-fc0c8b51813a

📥 Commits

Reviewing files that changed from the base of the PR and between a171cb1 and 158ac80.

📒 Files selected for processing (2)
  • crates/bmc-mock/src/machine_info.rs
  • crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs

Comment on lines 64 to +79
/// Whether the BlueField currently reports NIC mode.
pub fn nic_mode(&self) -> bool {
self.mode.lock().unwrap().nic_mode
match self {
Self::Bluefield3 { mode, .. } => mode.lock().unwrap().nic_mode,
Self::Bluefield4 => false,
}
}

/// Queue a `Mode.Set`; it takes effect on the next power cycle.
fn stage_mode(&self, nic_mode: bool) {
self.mode.lock().unwrap().pending_nic_mode = Some(nic_mode);
match self {
Self::Bluefield3 { mode, .. } => {
mode.lock().unwrap().pending_nic_mode = Some(nic_mode);
}
Self::Bluefield4 => (),
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify BF4 Mode.Set handling and downstream interpretation.
sed -n '108,131p' crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs
rg -nP -C3 '\bstage_mode\s*\(' crates/bmc-mock/src
rg -nP -C3 '\bbluefield_nic_mode\s*\(' crates

Repository: NVIDIA/infra-controller

Length of output: 4892


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the PATCH handler and surrounding BlueField state model.
sed -n '1,260p' crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs
printf '\n---\n'
sed -n '1,140p' crates/bmc-mock/src/bmc_state.rs
printf '\n---\n'
sed -n '380,430p' crates/machine-a-tron/src/machine_state_machine.rs
sed -n '800,830p' crates/machine-a-tron/src/machine_state_machine.rs

# Look for any BF4-specific handling or rejection in the mock BMC redfish code.
rg -nC2 'Bluefield4|Mode\.Set|patch_managers_oem_nvidia|parse_requested_mode|nic_mode\(' crates/bmc-mock/src

Repository: NVIDIA/infra-controller

Length of output: 34628


Reject unsupported BF4 mode changes instead of silently mapping them to false. Bluefield4 has no mode state, but nic_mode() collapses that to false and stage_mode() accepts Mode.Set as a no-op, so callers get a successful write for an unsupported operation. Return an unsupported/error result for BF4, or surface Option<bool> so absence stays distinct from DPU mode.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs` around lines 64 - 79,
Bluefield4 mode handling currently treats unsupported operations as a successful
no-op by returning false from nic_mode() and accepting stage_mode() without
error. Update the Bluefield enum handling so Bluefield3 and Bluefield4 are
distinguished in nic_mode() and stage_mode(), and make Bluefield4 return an
unsupported/error result for Mode.Set instead of silently mapping absence of
state to false; if needed, change the API to surface Option<bool> so callers can
tell “no mode” apart from DPU mode.

Source: Path instructions

@poroh poroh force-pushed the bmc-mock-bf4-nvidia-oem branch from 158ac80 to e59bdf4 Compare July 1, 2026 20:17
BF4 doesn't provide BaseMac and NicMode attributes in its
/redfish/v1/Systems/Bluefield/Oem/Nvidia path.

Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
@poroh poroh force-pushed the bmc-mock-bf4-nvidia-oem branch from e59bdf4 to 80097bc Compare July 1, 2026 20:47

@coderabbitai coderabbitai Bot 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.

♻️ Duplicate comments (1)
crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs (1)

60-94: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Unresolved: BF4 Mode.Set still silently succeeds instead of rejecting.

The enum refactor preserves the exact behavior flagged in a prior review: nic_mode() returns false for Bluefield4 and stage_mode()/apply_pending_mode() are silent no-ops. A caller issuing Mode.Set against a BF4 system therefore gets what looks like a successful write for an operation BF4 doesn't support, rather than a rejected/unsupported result. Since BF4 genuinely has no mode state (per PR objective), consider surfacing this at the PATCH handler level (reject Mode.Set for Bluefield4 with an error) instead of quietly absorbing it in stage_mode().

As per path instructions, BMC-facing code should account for vendor differences and avoid masking those differences behind uniform success responses.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs` around lines 60 - 94,
BF4 Mode.Set is still being treated as a no-op, so the PATCH path returns
success for an unsupported operation. Update the Redfish handler that calls
`stage_mode()` for Bluefield systems to explicitly reject `Mode.Set` when the
target is `Bluefield4`, and return an unsupported/error response instead of
silently absorbing it. Use the `Bluefield` enum match and the
`stage_mode`/`apply_pending_mode` flow to locate the change, and keep BF3’s
pending-mode behavior unchanged.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs`:
- Around line 60-94: BF4 Mode.Set is still being treated as a no-op, so the
PATCH path returns success for an unsupported operation. Update the Redfish
handler that calls `stage_mode()` for Bluefield systems to explicitly reject
`Mode.Set` when the target is `Bluefield4`, and return an unsupported/error
response instead of silently absorbing it. Use the `Bluefield` enum match and
the `stage_mode`/`apply_pending_mode` flow to locate the change, and keep BF3’s
pending-mode behavior unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 37c29eac-7c6f-4eec-bd07-0926675dd142

📥 Commits

Reviewing files that changed from the base of the PR and between e59bdf4 and 80097bc.

📒 Files selected for processing (3)
  • crates/bmc-mock/src/machine_info.rs
  • crates/bmc-mock/src/redfish/oem/nvidia/bluefield.rs
  • crates/site-explorer/tests/integration/site_explorer.rs
💤 Files with no reviewable changes (1)
  • crates/site-explorer/tests/integration/site_explorer.rs
✅ Files skipped from review due to trivial changes (1)
  • crates/bmc-mock/src/machine_info.rs

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🔍 Container Scan Summary

Service Total Critical High Medium Low Other
boot-artifacts-aarch64 3 0 0 3 0 0
boot-artifacts-x86_64 3 0 0 3 0 0
forge-admin-cli-x86_64 302 5 32 113 8 144
machine-validation-runner 769 25 208 278 37 221
machine_validation 769 25 208 278 37 221
machine_validation-aarch64 769 25 208 278 37 221
nvmetal-carbide 769 25 208 278 37 221
TOTAL 3384 105 864 1231 156 1028

Per-CVE detail lives in the per-service grype-* artifacts (JSON + SARIF). Severity counts only — no CVE IDs published here.

@poroh poroh merged commit b1a3418 into NVIDIA:main Jul 2, 2026
59 checks passed
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