[cli]: Add DPU recovery CLI commands for SmartSwitch#4572
Open
vvolam wants to merge 1 commit into
Open
Conversation
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced May 28, 2026
Extend 'show chassis modules status' with a Ready-Status column on SmartSwitch platforms. Add new 'show chassis modules recovery' command to expose detailed DPU recovery state (recovery_status, reset_count, last_down_time, last_ready_time) from CHASSIS_STATE_DB. Add unit tests for the new CLI commands. Signed-off-by: Vasundhara Volam <vvolam@nvidia.com> Signed-off-by: Vasundhara Volam <vvolam@microsoft.com>
1831f0e to
0b1de1a
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds DPU recovery visibility to the SmartSwitch CLI: a new Ready-Status column on show chassis modules status and a new show chassis modules recovery subcommand that surfaces ready/recovery state, reset counts, and last down/ready timestamps from CHASSIS_STATE_DB:DPU_STATE|DPU<N>.
Changes:
- Extend
show chassis modules statuson SmartSwitch with aReady-Statuscolumn sourced fromCHASSIS_STATE_DB. - Add new
show chassis modules recovery [<module>]subcommand (SmartSwitch-only) showing ready/recovery state, reset count, and timestamps. - Add
TestChassisModulesRecoveryunit tests covering all-DPU listing, single-DPU filter, non-SmartSwitch guard, no-data, missing-fields, unrecoverable DPU, and Ready-Status column rendering.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| show/chassis_modules.py | Adds DPU_STATE constants, CHASSIS_STATE_DB lookups, the Ready-Status column on status, and the new recovery subcommand. |
| tests/chassis_modules_test.py | Adds TestChassisModulesRecovery test class exercising the new column and recovery command across happy and edge cases. |
|
|
||
| ready_status = data_dict.get(DPU_STATE_READY_STATUS_FIELD, 'N/A') | ||
| recovery_status = data_dict.get(DPU_STATE_RECOVERY_STATUS_FIELD, 'N/A') | ||
| reset_count = data_dict.get(DPU_STATE_RESET_COUNT_FIELD, '0') |
Comment on lines
+160
to
+162
| if not keys: | ||
| click.echo('No DPU recovery data available') | ||
| return |
Comment on lines
+82
to
+93
| # For SmartSwitch, connect to CHASSIS_STATE_DB to read DPU_STATE | ||
| dpu_state_data = {} | ||
| if smartswitch: | ||
| chassis_state_db = SonicV2Connector(host=CHASSIS_SERVER, port=CHASSIS_SERVER_PORT) | ||
| chassis_state_db.connect(chassis_state_db.CHASSIS_STATE_DB) | ||
| dpu_key_pattern = DPU_STATE_TABLE + '|*' | ||
| dpu_keys = chassis_state_db.keys(chassis_state_db.CHASSIS_STATE_DB, dpu_key_pattern) | ||
| if dpu_keys: | ||
| for dpu_key in dpu_keys: | ||
| dpu_name = dpu_key.split('|')[1] | ||
| dpu_state_data[dpu_name] = chassis_state_db.get_all( | ||
| chassis_state_db.CHASSIS_STATE_DB, dpu_key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
Added CLI support for DPU recovery monitoring on SmartSwitch platforms as specified in the Enhance DPU Robustness HLD:
show chassis modules statuswith aReady-Statuscolumn on SmartSwitch platforms.show chassis modules recoverycommand to expose detailed DPU recovery state.How I did it
Modified
show/chassis_modules.py:statuscommand now connects toCHASSIS_STATE_DBand readsready_statusfromDPU_STATE|DPU<N>for each module, appending it as a new column.recoverysubcommand that readsready_status,recovery_status,reset_count,last_down_time, andlast_ready_timefromCHASSIS_STATE_DB: DPU_STATE|DPU<N>.recoverycommand is gated to SmartSwitch platforms only.Added unit tests in
tests/chassis_modules_test.py:TestChassisModulesRecoveryclass with 7 test cases covering all DPUs, single DPU filter, non-SmartSwitch guard, no-data scenario, Ready-Status in status command, unrecoverable DPU display, and missing fields handling.How to verify it
Previous command output (if the output of a command-line utility has changed)
New command output (if the output of a command-line utility has changed)