Skip to content

feat: ensure the boot config through one shared mechanism#3403

Open
chet wants to merge 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3391
Open

feat: ensure the boot config through one shared mechanism#3403
chet wants to merge 1 commit into
NVIDIA:mainfrom
chet:gh-issue-3391

Conversation

@chet

@chet chet commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

The state machine establishes a host's boot config once, early -- but the
stages that reboot hosts each grew their own way of noticing the config
drifted across a reboot and putting it back: machine validation carried four
ensure states, DPU reprovision carried a five-state host boot repair, and
every future reboot site was on its own. The mechanics were already shared;
the noticing, the routing, and the resume were not.

One mechanism now owns all of it. EnsureBootConfig is a top-level state with
a resume continuation: it checks whether the BMC is locked and unlocks it if
so, drives the boot-order flow to put the config back (verifying first and
re-applying only what drifted), re-locks per the expected-machine policy, and
resumes the interrupted state.

  • Machine validation and DPU reprovision's host boot repair now run through
    EnsureBootConfig; their old states remain only as thin compatibility shims
    that transition records parked in them into the shared flow.
  • Detection lives in one shared pacing call, pace_reboot_or_ensure_boot_config:
    pace reboots for a host that has not come back, and when its boot config
    reads drifted -- changed externally, a BIOS quirk, or the boot NIC dropping
    off the BMC's inventory during POST -- ensure it instead of rebooting forever.
  • The unlock step now tolerates vendors that report lockdown but cannot set it,
    matching the re-lock side.
  • State history and metrics show the activity under one name (ensurebootconfig)
    wherever it happens.

Tests updated!

This supports #3391

Signed-off-by: Chet Nichols III chetn@nvidia.com

@chet chet requested a review from a team as a code owner July 11, 2026 08:31
@chet

chet commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@chet, you're welcome! I'll kick off a full review of all the changes in this PR now.

(=^・ω・^=)

✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Summary by CodeRabbit

  • New Features
    • Added automatic boot-configuration drift repair during host validation and DPU reprovisioning.
    • Boot repair now handles lockdown, boot-order updates, verification, and relocking before resuming the interrupted workflow.
    • Improved recovery for hosts encountered in legacy boot-repair states.
  • Bug Fixes
    • Host and tenant statuses now remain accurate while boot-configuration repairs are in progress.
    • Improved restart and reboot handling when boot configuration changes are detected.
  • Monitoring
    • Added clearer state reporting for each boot-configuration repair stage.

Walkthrough

The PR introduces a shared EnsureBootConfig state machine for boot-lockdown handling, boot-order remediation, reboot pacing, and resumption. Machine validation and DPU reprovisioning use this flow, with updated state contracts, metrics, tenant projection, and tests.

Changes

Ensure boot configuration flow

Layer / File(s) Summary
EnsureBootConfig state contract
crates/api-model/src/machine/mod.rs, crates/machine-controller/src/io.rs
Adds the state and step enums, formatting, effective-state lookup, validation SLA routing, and step-specific metric labels.
Shared controller orchestration
crates/machine-controller/src/handler.rs
Dispatches and executes boot-configuration steps, including lockdown handling, boot-order application, reboot pacing, relocking, and resumption.
Machine validation integration
crates/machine-controller/src/handler/machine_validation.rs, crates/api-core/src/tests/machine_states.rs, crates/api-core/src/tests/common/api_fixtures/mod.rs
Routes validation repair states through EnsureBootConfig and adds coverage for drift recovery, legacy-state continuation, and state preservation.
DPU reprovision integration
crates/machine-controller/src/handler.rs, crates/api-core/src/tests/dpu_reprovisioning.rs
Replaces direct boot-order and relock transitions with shared steps and updates expected remediation sequences.
Tenant status projection
crates/rpc/src/model/instance/status/tenant.rs
Projects the resumed underlying state when a host is wrapped in EnsureBootConfig, with corresponding status coverage.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant attempt_state_transition
  participant ensure_boot_config
  participant BMC
  participant resume_to
  attempt_state_transition->>ensure_boot_config: dispatch step and resume target
  ensure_boot_config->>BMC: check, unlock, or relock lockdown
  ensure_boot_config->>BMC: apply boot order and pace reboot
  ensure_boot_config->>resume_to: resume validation or reprovisioning state
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: consolidating boot config handling into one shared mechanism.
Description check ✅ Passed The description accurately describes the shared EnsureBootConfig flow, legacy shims, pacing, and metrics changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% 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.

@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

🤖 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/api-core/src/tests/machine_states.rs`:
- Around line 3266-3313: Expand
test_pre_consolidation_validation_states_continue_via_ensure_boot_config into
table-driven cases covering RepairBootConfig, PrepareBootRepair,
UnlockForBootRepair, and LockAfterBootRepair. For each persisted legacy state,
assert the transition reaches the corresponding EnsureBootConfig recovery step
and that resume_to preserves the original validation ID at RebootHost; reuse the
shared setup and operation across cases.
🪄 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: 57712178-056c-4084-9277-5194c3a0a04b

📥 Commits

Reviewing files that changed from the base of the PR and between 76357e2 and 2fb4641.

📒 Files selected for processing (7)
  • crates/api-core/src/tests/common/api_fixtures/mod.rs
  • crates/api-core/src/tests/dpu_reprovisioning.rs
  • crates/api-core/src/tests/machine_states.rs
  • crates/api-model/src/machine/mod.rs
  • crates/machine-controller/src/handler.rs
  • crates/machine-controller/src/handler/machine_validation.rs
  • crates/machine-controller/src/io.rs

Comment thread crates/api-core/src/tests/machine_states.rs
@chet

chet commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@chet, you're welcome! Kicking off a full review of all the changes in this PR now.

(=^・ω・^=)

✅ Action performed

Full review finished.

@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

🤖 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 11391-11399: Update ensure_boot_config_apply_start and the
EnsureBootConfig flow so selecting Apply first evaluates
should_skip_boot_order_remediation(). When the skip applies, bypass only
boot-order remediation while preserving the BIOS repair path; otherwise retain
the existing Apply initialization and boot-order behavior.
🪄 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: 6268c332-4c65-41bb-83bb-396885714e9c

📥 Commits

Reviewing files that changed from the base of the PR and between 76357e2 and 6305ee2.

📒 Files selected for processing (7)
  • crates/api-core/src/tests/common/api_fixtures/mod.rs
  • crates/api-core/src/tests/dpu_reprovisioning.rs
  • crates/api-core/src/tests/machine_states.rs
  • crates/api-model/src/machine/mod.rs
  • crates/machine-controller/src/handler.rs
  • crates/machine-controller/src/handler/machine_validation.rs
  • crates/machine-controller/src/io.rs

Comment thread crates/machine-controller/src/handler.rs
@chet

chet commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@chet, you're welcome! Kicking off another full review of all the changes in this PR now.

(=^・ω・^=)

✅ Action performed

Full review finished.

@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

🤖 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 3347-3356: Update the legacy compatibility transition using
ensure_for_reprovision_tail to select EnsureBootConfigStep::Relock when
should_skip_boot_order_remediation(state) is true, matching the current
SetBootOrder path; otherwise retain the existing EnsureBootConfigStep::Apply
with cloned set_boot_order_info.
🪄 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: c73d7ac9-7c7d-4dc1-81d3-320a2ce16e7f

📥 Commits

Reviewing files that changed from the base of the PR and between 76357e2 and 3f64062.

📒 Files selected for processing (7)
  • crates/api-core/src/tests/common/api_fixtures/mod.rs
  • crates/api-core/src/tests/dpu_reprovisioning.rs
  • crates/api-core/src/tests/machine_states.rs
  • crates/api-model/src/machine/mod.rs
  • crates/machine-controller/src/handler.rs
  • crates/machine-controller/src/handler/machine_validation.rs
  • crates/machine-controller/src/io.rs

Comment thread crates/machine-controller/src/handler.rs
@github-actions

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 271 13 34 91 7 126
machine-validation-runner 804 40 237 296 36 195
machine_validation 804 40 237 296 36 195
machine_validation-aarch64 804 40 237 296 36 195
nvmetal-carbide 804 40 237 296 36 195
TOTAL 3493 173 982 1281 151 906

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

@chet

chet commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@chet, you're welcome! Kicking off another full review of all the changes in this PR now.

(=^・ω・^=)

✅ Action performed

Full review finished.

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

🧹 Nitpick comments (1)
crates/machine-controller/src/handler.rs (1)

11366-11644: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

CheckLockdown/Unlock logic is now duplicated between ensure_boot_config and the still-inline ReprovisionState::PrepareHostBootRepair/UnlockHostForBootRepair arms.

The new step machine re-implements the same lockdown-check → unlock (with the Supermicro reboot special-case and WaitForUefiBoot pacing) that handle_dpu_reprovision's PrepareHostBootRepair/UnlockHostForBootRepair arms still run inline (lines ~3033-3146, unchanged). Only the boot-order/relock tail was migrated to the shared flow per this PR's scope, leaving two parallel implementations of the unlock choreography. Any future vendor-specific fix (e.g. another quirky BMC) now needs to be applied in both places to stay consistent.

Worth tracking as a follow-up to fully consolidate DPU reprovision's host-boot-repair entry (PrepareHostBootRepair/UnlockHostForBootRepair) onto EnsureBootConfigStep::CheckLockdown/Unlock in a later pass, rather than as part of this PR.

🤖 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 11366 - 11644,
Consolidate the duplicated lockdown-check and unlock choreography by migrating
the inline ReprovisionState::PrepareHostBootRepair and UnlockHostForBootRepair
handling in handle_dpu_reprovision to EnsureBootConfigStep::CheckLockdown and
Unlock. Preserve the Supermicro reboot special case and WaitForUefiBoot pacing,
and remove the parallel inline implementation so future vendor-specific changes
are centralized in ensure_boot_config.
🤖 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.

Nitpick comments:
In `@crates/machine-controller/src/handler.rs`:
- Around line 11366-11644: Consolidate the duplicated lockdown-check and unlock
choreography by migrating the inline ReprovisionState::PrepareHostBootRepair and
UnlockHostForBootRepair handling in handle_dpu_reprovision to
EnsureBootConfigStep::CheckLockdown and Unlock. Preserve the Supermicro reboot
special case and WaitForUefiBoot pacing, and remove the parallel inline
implementation so future vendor-specific changes are centralized in
ensure_boot_config.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d5cca6d7-35ad-48c2-8905-330a4b63c7d8

📥 Commits

Reviewing files that changed from the base of the PR and between 76357e2 and 1924521.

📒 Files selected for processing (7)
  • crates/api-core/src/tests/common/api_fixtures/mod.rs
  • crates/api-core/src/tests/dpu_reprovisioning.rs
  • crates/api-core/src/tests/machine_states.rs
  • crates/api-model/src/machine/mod.rs
  • crates/machine-controller/src/handler.rs
  • crates/machine-controller/src/handler/machine_validation.rs
  • crates/machine-controller/src/io.rs

@chet

chet commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Ran the pre-merge agent-review pass (self-review + Codex) per our review workflow; three findings, all verified against the code and taken:

  • Continuation transparency (the class): code that matches on outer states could not see through EnsureBootConfig -- an operator DPU-reprovision restart submitted mid-ensure was silently discarded, and an assigned host mid-ensure reported Invalid tenant status instead of Updating. Added ManagedHostState::effective_state() (peels EnsureBootConfig to its resume_to) and applied it at both sites, with a tenant-status test covering the wrapper.
  • Viking parked-record BIOS ensure: normalizing legacy mid-chain records to Relock on DGX H100/Viking could skip a still-needed BIOS correction. Both shims now restart the flow from the top instead -- the BIOS side gets ensured and the flow itself skips the boot order on that hardware.

Also re-audited the review-round changes against the style guide (post-review house-conformance check): clean; one deliberate semantic worth reviewer eyes -- the engine-level skip means DGX H100/Viking hosts no longer attempt the boot-order write during first provisioning either (uniform policy, previously attempted).

Full suite green (1449) with the changes.

@chet

chet commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

@chet, you're welcome! Kicking off another full review of all the changes in this PR now.

(=^・ω・^=)

✅ Action performed

Full review finished.

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

🧹 Nitpick comments (1)
crates/rpc/src/model/instance/status/tenant.rs (1)

56-58: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Match the effective state by reference instead of cloning it.

Every branch only inspects the state, so Line 58 unnecessarily clones structures such as the DPU reprovision map on each status projection.

Proposed change
-    let machine_state = machine_state.effective_state().clone();
+    let machine_state = machine_state.effective_state();

As per coding guidelines and path instructions, “Avoid needless clones.”

🤖 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/rpc/src/model/instance/status/tenant.rs` around lines 56 - 58, Update
the machine_state binding in the status projection to borrow the result of
effective_state() rather than cloning it. Preserve the existing state inspection
logic and adjust any downstream matching or references to operate on the
borrowed state.

Sources: Coding guidelines, 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.

Nitpick comments:
In `@crates/rpc/src/model/instance/status/tenant.rs`:
- Around line 56-58: Update the machine_state binding in the status projection
to borrow the result of effective_state() rather than cloning it. Preserve the
existing state inspection logic and adjust any downstream matching or references
to operate on the borrowed state.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e255945a-787b-4489-8521-137cd5b16289

📥 Commits

Reviewing files that changed from the base of the PR and between 1924521 and d690b0f.

📒 Files selected for processing (8)
  • crates/api-core/src/tests/common/api_fixtures/mod.rs
  • crates/api-core/src/tests/dpu_reprovisioning.rs
  • crates/api-core/src/tests/machine_states.rs
  • crates/api-model/src/machine/mod.rs
  • crates/machine-controller/src/handler.rs
  • crates/machine-controller/src/handler/machine_validation.rs
  • crates/machine-controller/src/io.rs
  • crates/rpc/src/model/instance/status/tenant.rs
🚧 Files skipped from review as they are similar to previous changes (7)
  • crates/api-core/src/tests/common/api_fixtures/mod.rs
  • crates/machine-controller/src/io.rs
  • crates/api-model/src/machine/mod.rs
  • crates/api-core/src/tests/machine_states.rs
  • crates/api-core/src/tests/dpu_reprovisioning.rs
  • crates/machine-controller/src/handler/machine_validation.rs
  • crates/machine-controller/src/handler.rs

@chet

chet commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

@chet, you're welcome! Kicking off another full review of all the changes in this PR now.

(=^・ω・^=)

✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 7 minutes.

@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/rpc/src/model/instance/status/tenant.rs (1)

56-58: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid cloning the full effective state.

effective_state().clone() deep-clones the resumed state, including DPU reprovision maps, although this match only reads it. Match the borrowed effective state directly.

Proposed fix
-    let machine_state = machine_state.effective_state().clone();
+    let machine_state = machine_state.effective_state();

As per coding guidelines, “Avoid needless clones”; as per path instructions, Rust changes should avoid needless clones.

🤖 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/rpc/src/model/instance/status/tenant.rs` around lines 56 - 58, Update
the machine-state handling near effective_state() to match or otherwise read the
borrowed effective state directly instead of calling clone(). Preserve the
existing resumed-state behavior while avoiding a deep clone of the effective
state and its DPU reprovision maps.

Sources: Coding guidelines, 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.

Inline comments:
In `@crates/machine-controller/src/handler.rs`:
- Around line 11433-11449: Update the reboot-wait verification around the
is_bios_setup check to also validate boot order via is_boot_order_setup, while
honoring the existing hardware condition that intentionally skips boot-order
remediation. If either BIOS setup or applicable boot-order configuration has
drifted, transition to EnsureBootConfig with CheckLockdown instead of proceeding
to another reboot.

---

Nitpick comments:
In `@crates/rpc/src/model/instance/status/tenant.rs`:
- Around line 56-58: Update the machine-state handling near effective_state() to
match or otherwise read the borrowed effective state directly instead of calling
clone(). Preserve the existing resumed-state behavior while avoiding a deep
clone of the effective state and its DPU reprovision maps.
🪄 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: cee71d0a-d6ae-4bdf-b056-99b54e7cb81e

📥 Commits

Reviewing files that changed from the base of the PR and between 6a5316b and d690b0f.

📒 Files selected for processing (8)
  • crates/api-core/src/tests/common/api_fixtures/mod.rs
  • crates/api-core/src/tests/dpu_reprovisioning.rs
  • crates/api-core/src/tests/machine_states.rs
  • crates/api-model/src/machine/mod.rs
  • crates/machine-controller/src/handler.rs
  • crates/machine-controller/src/handler/machine_validation.rs
  • crates/machine-controller/src/io.rs
  • crates/rpc/src/model/instance/status/tenant.rs

Comment thread crates/machine-controller/src/handler.rs Outdated
The state machine establishes a host's boot config once, early -- but the
stages that reboot hosts each grew their own way of noticing the config
drifted across a reboot and putting it back: machine validation carried four
ensure states, DPU reprovision carried a five-state host boot repair, and
every future reboot site was on its own. The mechanics were already shared;
the noticing, the routing, and the resume were not.

One mechanism now owns all of it. EnsureBootConfig is a top-level state with
a resume continuation: it checks whether the BMC is locked and unlocks it if
so, drives the boot-order flow to put the config back (verifying first and
re-applying only what drifted), re-locks per the expected-machine policy, and
resumes the interrupted state.

- Machine validation and DPU reprovision's host boot repair now run through
  EnsureBootConfig; their old states remain only as thin compatibility shims
  that transition records parked in them into the shared flow.
- Detection lives in one shared pacing call, pace_reboot_or_ensure_boot_config:
  pace reboots for a host that has not come back, and when its boot config
  reads drifted -- changed externally, a BIOS quirk, or the boot NIC dropping
  off the BMC's inventory during POST -- ensure it instead of rebooting forever.
- The unlock step now tolerates vendors that report lockdown but cannot set it,
  matching the re-lock side.
- State history and metrics show the activity under one name (ensurebootconfig)
  wherever it happens.

Tests updated!

This supports NVIDIA#3391

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
@chet

chet commented Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

@chet, you're welcome! Kicking off another full review of all the changes in this PR now.

(=^・ω・^=)

✅ Action performed

Full review finished.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/machine-controller/src/handler.rs (1)

1832-1873: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Pass the resumed state into the reprovision resolver
The dispatch now uses effective_state(), but next_state_with_all_dpus_updated only accepts Ready, DPUReprovision, or Assigned reprovision states. Passing state.managed_state here will reject an EnsureBootConfig wrapper on the restart path. Use the unwrapped state consistently.

🤖 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 1832 - 1873, Update
the DPUReprovision branch in the effective_state dispatch to pass the unwrapped
resumed state into next_state_with_all_dpus_updated instead of
state.managed_state. Use the same effective-state value resolved for dispatch so
EnsureBootConfig wrappers are accepted while preserving existing handling for
Ready, DPUReprovision, and Assigned states.

Source: Path instructions

🧹 Nitpick comments (1)
crates/rpc/src/model/instance/status/tenant.rs (1)

56-58: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid cloning the resumed state for status projection.

effective_state() already returns a borrow; matching it directly avoids cloning potentially large DPU reprovision maps.

Proposed change
-    let machine_state = machine_state.effective_state().clone();
+    let machine_state = machine_state.effective_state();

As per coding guidelines and path instructions, “Avoid needless clones.”

🤖 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/rpc/src/model/instance/status/tenant.rs` around lines 56 - 58, Update
the machine_state assignment in the status projection to retain the borrow
returned by effective_state() instead of cloning the resumed state. Adjust
subsequent matching or usage to work with the borrowed value while preserving
the existing status behavior.

Sources: Coding guidelines, 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.

Outside diff comments:
In `@crates/machine-controller/src/handler.rs`:
- Around line 1832-1873: Update the DPUReprovision branch in the effective_state
dispatch to pass the unwrapped resumed state into
next_state_with_all_dpus_updated instead of state.managed_state. Use the same
effective-state value resolved for dispatch so EnsureBootConfig wrappers are
accepted while preserving existing handling for Ready, DPUReprovision, and
Assigned states.

---

Nitpick comments:
In `@crates/rpc/src/model/instance/status/tenant.rs`:
- Around line 56-58: Update the machine_state assignment in the status
projection to retain the borrow returned by effective_state() instead of cloning
the resumed state. Adjust subsequent matching or usage to work with the borrowed
value while preserving the existing status behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 15de047d-ad8b-4173-91e3-53f0615f1fd0

📥 Commits

Reviewing files that changed from the base of the PR and between 6a5316b and 686810f.

📒 Files selected for processing (8)
  • crates/api-core/src/tests/common/api_fixtures/mod.rs
  • crates/api-core/src/tests/dpu_reprovisioning.rs
  • crates/api-core/src/tests/machine_states.rs
  • crates/api-model/src/machine/mod.rs
  • crates/machine-controller/src/handler.rs
  • crates/machine-controller/src/handler/machine_validation.rs
  • crates/machine-controller/src/io.rs
  • crates/rpc/src/model/instance/status/tenant.rs

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.

1 participant