Skip to content

fix(ipmi): use Redfish-discovered port for power operations - #4135

Merged
poroh merged 1 commit into
NVIDIA:mainfrom
poroh:ipmi-tool-port-plumbing
Jul 27, 2026
Merged

fix(ipmi): use Redfish-discovered port for power operations#4135
poroh merged 1 commit into
NVIDIA:mainfrom
poroh:ipmi-tool-port-plumbing

Conversation

@poroh

@poroh poroh commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Redfish discovery records the BMC's advertised IPMI port, but IPMI power operations currently use only the BMC IP address. As a result, ipmitool implicitly connects to port 623 even when discovery reported a different port.

This PR carries the complete BMC socket address through the IPMI interface and uses the port stored in the discovered endpoint metadata.

Specifically, it:

  • changes IPMITool operations to accept a SocketAddr;
  • resolves the discovered IPMI port before machine restart and BMC cold-reset operations;
  • falls back to the standard IPMI port, 623, when discovery did not report one;
  • passes the selected port to ipmitool with -p;

Related issues

Related: #3803

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

Support for handling IPMI reboot commands in bmc-mock is intentionally kept in a separate change so the two updates can be reviewed and merged independently.

@copy-pr-bot

copy-pr-bot Bot commented Jul 24, 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 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • New Features

    • IPMI connections now support explicit host and port addresses.
    • Configured BMC-specific IPMI ports are used when available, with port 623 as the default.
    • IPMI command execution and simulator interactions now consistently honor the target port.
  • Bug Fixes

    • Improved routing for IPMI resets and restarts when non-default ports are configured.

Walkthrough

IPMI addressing now uses SocketAddr values across interfaces, command execution, mocks, and callers. The shared default port is 623, while machine-controller resolution preserves reported BMC ports and falls back to the default.

Changes

IPMI socket addressing

Layer / File(s) Summary
IPMI address contract
crates/ipmi/src/lib.rs, crates/ipmi/src/test_support.rs
The IPMI trait and test implementation accept SocketAddr, and DEFAULT_IPMI_PORT is defined as 623.
IPMI command and mock execution
crates/ipmi/src/tool.rs, crates/ipmi/src/bmc_mock.rs
ipmitool receives the target host and port, while mock HTTP requests derive host values from the socket address.
IPMI address resolution and callers
crates/machine-controller/src/handler.rs, crates/site-explorer/src/bmc_endpoint_explorer.rs, crates/machine-a-tron/src/bmc_mock_wrapper.rs, crates/machine-a-tron/Cargo.toml
Callers construct socket addresses using reported ports or the shared default, and the simulator uses the shared IPMI dependency and port constant.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MachineController
  participant IPMITool
  participant ipmitool
  participant BmcMock
  MachineController->>IPMITool: pass resolved SocketAddr
  IPMITool->>ipmitool: build host and port arguments
  IPMITool->>BmcMock: forward SocketAddr for reset
  BmcMock->>BmcMock: derive IP for HTTP request headers
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: using the Redfish-discovered IPMI port for power operations.
Description check ✅ Passed The description is directly aligned with the code changes and clearly explains the SocketAddr and port-handling updates.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
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 force-pushed the ipmi-tool-port-plumbing branch from a88552b to 7c109e5 Compare July 24, 2026 23:52
@poroh
poroh marked this pull request as ready for review July 24, 2026 23:55
@poroh
poroh requested a review from a team as a code owner July 24, 2026 23:55

@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/ipmi/src/tool.rs (1)

190-199: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use table-driven cases for the address-mapping tests.

Both tests map inputs to deterministic outputs; express their cases with the repository’s table-driven test helpers.

  • crates/ipmi/src/tool.rs#L190-L199: represent address/username and expected argument-tail combinations as table cases.
  • crates/machine-controller/src/handler.rs#L11963-L11975: represent reported-port and fallback-port expectations as table cases.
🤖 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/ipmi/src/tool.rs` around lines 190 - 199, The address-mapping tests
are separate deterministic cases and should use table-driven test helpers. In
crates/ipmi/src/tool.rs lines 190-199, update
connection_args_include_non_default_port to iterate over cases containing the
address, username, and expected argument tail. In
crates/machine-controller/src/handler.rs lines 11963-11975, convert the
reported-port and fallback-port assertions into equivalent table cases; preserve
each existing input and expected output.

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/machine-controller/src/handler.rs`:
- Around line 10716-10718: Update the error message constructed in the map_err
closure to begin with lowercase “ipmi restart failed” while preserving the
machine ID and underlying error details.

---

Nitpick comments:
In `@crates/ipmi/src/tool.rs`:
- Around line 190-199: The address-mapping tests are separate deterministic
cases and should use table-driven test helpers. In crates/ipmi/src/tool.rs lines
190-199, update connection_args_include_non_default_port to iterate over cases
containing the address, username, and expected argument tail. In
crates/machine-controller/src/handler.rs lines 11963-11975, convert the
reported-port and fallback-port assertions into equivalent table cases; preserve
each existing input and expected output.
🪄 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: 0659a52d-9004-4524-b394-e7d5956279e8

📥 Commits

Reviewing files that changed from the base of the PR and between 4086ce1 and 7c109e5.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • crates/ipmi/src/bmc_mock.rs
  • crates/ipmi/src/lib.rs
  • crates/ipmi/src/test_support.rs
  • crates/ipmi/src/tool.rs
  • crates/machine-a-tron/Cargo.toml
  • crates/machine-a-tron/src/bmc_mock_wrapper.rs
  • crates/machine-controller/src/handler.rs
  • crates/site-explorer/src/bmc_endpoint_explorer.rs

Comment on lines 10716 to 10718
.map_err(|e| {
StateHandlerError::GenericError(eyre!("IPMI restart failed for {}: {}", machine.id, e))
})

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Lowercase the error message on Line 10717.

Use ipmi restart failed ...; repository error display messages must start with lowercase text.

🤖 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/machine-controller/src/handler.rs` around lines 10716 - 10718, Update
the error message constructed in the map_err closure to begin with lowercase
“ipmi restart failed” while preserving the machine ID and underlying error
details.

Source: Coding guidelines

@poroh
poroh merged commit a856f76 into NVIDIA:main Jul 27, 2026
62 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