Skip to content

fix(machine-a-tron): invalidate stale boot actions - #4430

Merged
jayzhudev merged 1 commit into
NVIDIA:mainfrom
jayzhudev:fix/invalidate-stale-boot-actions
Jul 31, 2026
Merged

fix(machine-a-tron): invalidate stale boot actions#4430
jayzhudev merged 1 commit into
NVIDIA:mainfrom
jayzhudev:fix/invalidate-stale-boot-actions

Conversation

@jayzhudev

@jayzhudev jayzhudev commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

A retrying Machine-a-Tron boot action can remain at the front of the action queue after a power change. This prevents the queued power-off cleanup and power-cycle timer from running. In the observed failure, a stale
InitialDiscoveryRequest kept retrying while the BIOS job remained scheduled until the test timed out.

This change invalidates work tied to the previous boot when the machine powers off or cycles. BMC-scoped setup, BMC DHCP, and existing power-off cleanup remain queued. Pending machine and agent deadlines are cleared.

Action classification uses an exhaustive match so future FsmAction, Timer, or BmcEvent variants require an explicit power-change policy.

Related issues

Resolves #4429

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

@jayzhudev jayzhudev self-assigned this Jul 31, 2026
@jayzhudev
jayzhudev requested a review from a team as a code owner July 31, 2026 03:12
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5b7e422f-bbad-4314-bbca-7d360a8e64d2

📥 Commits

Reviewing files that changed from the base of the PR and between 444e00b and 30d832b.

📒 Files selected for processing (1)
  • crates/machine-a-tron/src/machine_state_machine.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/machine-a-tron/src/machine_state_machine.rs

Summary by CodeRabbit

  • Bug Fixes
    • Improved machine power-change cleanup by removing outdated queued operations from the previous boot.
    • Preserved essential BMC setup, BMC DHCP, and power-off cleanup actions.
    • Ensured DHCP retry state resets appropriately when machine DHCP work is discarded.
  • Tests
    • Added coverage for retaining required actions and abandoning obsolete operations.

Walkthrough

Power-change cleanup now removes stale machine-side actions from the queue while retaining BMC setup, BMC DHCP, and power-off cleanup actions. Machine DHCP retry state resets only when machine DHCP work is removed. Tests cover these rules.

Changes

Power-change cleanup

Layer / File(s) Summary
Implement and wire power-change cleanup
crates/machine-a-tron/src/machine_state_machine.rs
The cleanup helper removes stale machine work, preserves BMC and power-off actions, resets machine DHCP retry state when required, and handles power-cycle and power-off events.
Validate queued-action behavior
crates/machine-a-tron/src/machine_state_machine.rs
Tests cover abandoned machine actions, retained BMC and power-off actions, unchanged state without machine work, and the replacement cleanup helper.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: invalidating stale boot actions after a power change.
Description check ✅ Passed The description accurately explains the stale-action bug, the fix, retained work, cleared deadlines, and test coverage.
Linked Issues check ✅ Passed The changes satisfy issue #4429 by abandoning stale boot-scoped actions while preserving BMC-scoped work and power-transition actions.
Out of Scope Changes check ✅ Passed The changes are limited to power-change action cleanup and related tests, which directly support issue #4429.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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.

🧹 Nitpick comments (1)
crates/machine-a-tron/src/machine_state_machine.rs (1)

1626-1627: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the power-change integration path.

This test calls the cleanup helper directly. It does not verify that fsm_event invokes the helper for both Event::PowerCycle and Event::PowerOff, or that the pending deadlines are cleared.

Add focused table cases through the power-change entry point and assert the queue, retry state, and deadlines.

🤖 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-a-tron/src/machine_state_machine.rs` around lines 1626 - 1627,
Add focused table-driven tests through the fsm_event power-change entry point
rather than calling abandon_machine_actions_on_power_change directly. Cover both
Event::PowerCycle and Event::PowerOff, asserting that actions are cleared, retry
state is updated, and pending deadlines are cleared.
🤖 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-a-tron/src/machine_state_machine.rs`:
- Around line 1626-1627: Add focused table-driven tests through the fsm_event
power-change entry point rather than calling
abandon_machine_actions_on_power_change directly. Cover both Event::PowerCycle
and Event::PowerOff, asserting that actions are cleared, retry state is updated,
and pending deadlines are cleared.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1e4441b3-45d4-4ea2-9617-f99b43b754b5

📥 Commits

Reviewing files that changed from the base of the PR and between 395a11f and 444e00b.

📒 Files selected for processing (1)
  • crates/machine-a-tron/src/machine_state_machine.rs

Power changes could leave a retrying discovery action at the queue head,
preventing cleanup and reboot timers from running.

Discard actions tied to the previous boot, clear pending deadlines, and
preserve BMC-scoped work. Exhaustive classification forces new action
variants to declare their power-change behavior.

Signed-off-by: Jay Zhu <jayzhu@nvidia.com>
@jayzhudev
jayzhudev force-pushed the fix/invalidate-stale-boot-actions branch from 444e00b to 30d832b Compare July 31, 2026 03:29
@jayzhudev
jayzhudev merged commit 5733ce7 into NVIDIA:main Jul 31, 2026
62 checks passed
polarweasel pushed a commit to polarweasel/infra-controller that referenced this pull request Jul 31, 2026
A retrying Machine-a-Tron boot action can remain at the front of the
action queue after a power change. This prevents the queued power-off
cleanup and power-cycle timer from running. In the observed failure, a
stale
`InitialDiscoveryRequest` kept retrying while the BIOS job remained
scheduled until the test timed out.

This change invalidates work tied to the previous boot when the machine
powers off or cycles. BMC-scoped setup, BMC DHCP, and existing power-off
cleanup remain queued. Pending machine and agent deadlines are cleared.

Action classification uses an exhaustive match so future `FsmAction`,
`Timer`, or `BmcEvent` variants require an explicit power-change policy.

## Related issues

Resolves NVIDIA#4429

## Type of Change

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

## Breaking Changes

- [ ] **This PR contains breaking changes**

## Testing

- [x] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing performed
- [ ] No testing required (docs, internal refactor, etc.)

Signed-off-by: Jay Zhu <jayzhu@nvidia.com>
Signed-off-by: Alex Ball <aball@nvidia.com>
chet added a commit that referenced this pull request Jul 31, 2026
#4454)

After #4430 fixed the stale Machine-a-Tron action queue, the rack
integration test exposed a second ordering problem: the controller could
enter the `On` phase before the BMC had actually applied `ForceOff`.

So, this gives the observed power-off its own persisted
`WaitingForPlatformPowerOff` phase. `ForceOff` is issued once, stale
power readings stay parked there, and the existing idempotent `On` phase
remains restart-safe if the process exits between the Redfish request
and state commit.

Tests added!

## Related issues

- Closes #4446
- Docs follow-up: #4452

## Type of Change

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

## Breaking Changes

- [ ] **This PR contains breaking changes**

No configuration or API changes are required.

## Testing

- [x] Unit tests added/updated
- [x] Integration tests added/updated
- [ ] Manual testing performed
- [ ] No testing required (docs, internal refactor, etc.)

- `cargo test -p carbide-machine-controller --test integration
dpu_init_power_cycle_waits_for_observed_host_power_off -- --nocapture`
- `cargo test -p carbide-api-core
tests::machine_history::test_machine_state_history --lib -- --nocapture`
- `cargo make check-format-nightly`
- `cargo make clippy`
- `cargo make carbide-lints`

## Additional Notes

- `WaitingForPlatformPowerOff` remains part of the existing
`waitingforplatformpowercycle` metric so dashboards and label
cardinality do not change.
- The controller still issues one `ForceOff`, matching the existing
behavior. A separate retry policy is outside this fix.
- The architecture diagram update stays in the docs-only follow-up so
tech-writer review does not block this controller change.

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
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.

bug: stale discovery action can block power-cycle completion (MAT)

2 participants