Skip to content

[action] [PR:203] [NPU-driven HA] Ack standalone before peer activates dead role#204

Merged
mssonicbld merged 1 commit into
sonic-net:202605from
mssonicbld:cherry/202605/203
Jul 6, 2026
Merged

[action] [PR:203] [NPU-driven HA] Ack standalone before peer activates dead role#204
mssonicbld merged 1 commit into
sonic-net:202605from
mssonicbld:cherry/202605/203

Conversation

@mssonicbld

Copy link
Copy Markdown

Description of PR

Summary:
During a planned shutdown of a standby HA scope, the active side previously gated its transition from Active to Standalone on the standby peer entering the Dead role. This ordering is incorrect: the active must ack the standalone role first so that it owns all traffic before the standby activates its dead role. Otherwise there is a window where the active is still in SwitchingToStandalone while the standby has already dropped out, leaving traffic unowned / inline sync unacked.

This PR flips the ordering so the active acks standalone first, and the standby only activates its dead role after observing the active's standalone ack.

Fixes # (N/A)

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation update
  • Test improvement

Approach

What is the motivation for this PR?

Correct the NPU-driven HA planned-shutdown state-transition ordering to avoid a traffic-ownership gap between the active and standby HA scopes.

How did you do it?

  • Active side (apply_pending_state_side_effects, SwitchingToStandalone): on PeerShutdownRequested, enter Standalone immediately instead of waiting for the peer to become Dead.
  • Standby side (next_state): gate the transition to Destroying (dead-role activation) on the active peer having acked the standalone role — both in the forced Shutdown path and via a new Standby branch that fires when the peer's acked ASIC role becomes standalone during a planned shutdown (desired_ha_state == Dead).

How did you verify/test it?

  • Updated the affected NPU-driven unit tests (ha_scope_npu_launch_to_standby_then_down, ha_scope_npu_active_to_standalone_on_peer_shutdown_and_peer_rejoin, ha_scope_npu_standby_planned_shutdown_and_relaunch_to_standby) to reflect the new ordering.
  • cargo test -p hamgrd --bin hamgrd actors::ha_scope — all 13 tests pass.
  • cargo fmt -- --check clean; cargo clippy -p hamgrd reports no new warnings.

Any platform specific information?

NPU-driven HA only. DPU-driven mode is unaffected.

Documentation

N/A — behavior fix aligned with the SmartSwitch HA HLD planned-shutdown flow.

Signed-off-by: Sonic Build Admin sonicbld@microsoft.com

### Description of PR

Summary:
During a planned shutdown of a standby HA scope, the active side previously gated its transition from `Active` to `Standalone` on the standby peer entering the `Dead` role. This ordering is incorrect: the active must ack the standalone role **first** so that it owns all traffic before the standby activates its dead role. Otherwise there is a window where the active is still in `SwitchingToStandalone` while the standby has already dropped out, leaving traffic unowned / inline sync unacked.

This PR flips the ordering so the active acks standalone first, and the standby only activates its dead role after observing the active's standalone ack.

Fixes # (N/A)

### Type of change

- [x] Bug fix
- [ ] New feature
- [ ] Refactor / cleanup
- [ ] Documentation update
- [ ] Test improvement

### Approach
#### What is the motivation for this PR?
Correct the NPU-driven HA planned-shutdown state-transition ordering to avoid a traffic-ownership gap between the active and standby HA scopes.

#### How did you do it?
- **Active side** (`apply_pending_state_side_effects`, `SwitchingToStandalone`): on `PeerShutdownRequested`, enter `Standalone` immediately instead of waiting for the peer to become `Dead`.
- **Standby side** (`next_state`): gate the transition to `Destroying` (dead-role activation) on the active peer having acked the `standalone` role — both in the forced `Shutdown` path and via a new `Standby` branch that fires when the peer's acked ASIC role becomes `standalone` during a planned shutdown (`desired_ha_state == Dead`).

#### How did you verify/test it?
- Updated the affected NPU-driven unit tests (`ha_scope_npu_launch_to_standby_then_down`, `ha_scope_npu_active_to_standalone_on_peer_shutdown_and_peer_rejoin`, `ha_scope_npu_standby_planned_shutdown_and_relaunch_to_standby`) to reflect the new ordering.
- `cargo test -p hamgrd --bin hamgrd actors::ha_scope` — all 13 tests pass.
- `cargo fmt -- --check` clean; `cargo clippy -p hamgrd` reports no new warnings.

#### Any platform specific information?
NPU-driven HA only. DPU-driven mode is unaffected.

### Documentation
N/A — behavior fix aligned with the SmartSwitch HA HLD planned-shutdown flow.

Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
@mssonicbld

Copy link
Copy Markdown
Author

Original PR: #203

@mssonicbld

Copy link
Copy Markdown
Author

/azp run

@azure-pipelines

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

@mssonicbld
mssonicbld merged commit 1a5778e into sonic-net:202605 Jul 6, 2026
4 checks passed
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.

1 participant