Skip to content

[chassisd] Record operator in DPU reboot-cause 'user' field - #841

Draft
vvolam wants to merge 1 commit into
sonic-net:masterfrom
vvolam:reboot-cause-user-field
Draft

vvolam wants to merge 1 commit into
sonic-net:masterfrom
vvolam:reboot-cause-user-field

Conversation

@vvolam

@vvolam vvolam commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Description

DPU reboot-cause history records written by chassisd hardcoded the dict in
persist_dpu_reboot_cause() without a user key, so when
update_dpu_reboot_cause_to_db() deletes and rewrites the
REBOOT_CAUSE|DPU<N>|* keys in CHASSIS_STATE_DB, the user field
disappeared — diverging from process-reboot-cause (sonic-host-services),
which always writes user.

This change:

  • Adds the user field to the persisted DPU reboot-cause record.
  • Populates it with the operator who triggered a user-initiated DPU
    reboot/shutdown, read from a one-shot marker
    /host/reboot-cause/module/<dpu>/prev_reboot_user.txt written by the
    sonic-utilities producers (reboot_smartswitch_helper and
    config chassis modules shutdown — see companion PR). chassisd reads the
    marker via retrieve_dpu_reboot_user() and removes it after use.
  • Defaults user to N/A for hardware/auto-detected reboots where no
    marker exists, matching the NPU determine-reboot-cause default and keeping
    the JSON schema consistent with process-reboot-cause.

Motivation and Context

Addresses sonic-net/sonic-buildimage#28149 — on SmartSwitch, DPU reboot-cause
entries were schema-inconsistent because chassisd omitted the user field
when rewriting CHASSIS_STATE_DB. Beyond just restoring schema parity, this
attributes user-initiated DPU reboots/shutdowns, mirroring the NPU
reboot-cause user field shown by show reboot-cause history.

Producer (marker-writer) companion PR in sonic-utilities: sonic-net/sonic-utilities#4653

How Has This Been Tested?

Unit tests — full sonic-chassisd suite passes (53 tests). New/updated cases:

  • test_persist_dpu_reboot_cause_includes_user_fielduser present, defaults to N/A.
  • test_persist_dpu_reboot_cause_records_user_for_user_initiated_reboot — records the marker user (admin).
  • test_retrieve_dpu_reboot_user — returns the user when the marker is present, N/A when empty/missing.

Manual (SmartSwitch DUT):

  1. Trigger a user-initiated DPU reboot (reboot -d DPU0) or shutdown (config chassis modules shutdown DPU0).
  2. After chassisd processes it: redis-cli -h redis_chassis.server -p 6380 -n 13 HGETALL "REBOOT_CAUSE|DPU0|<name>"user = operator.
  3. Hardware/auto reboot → user = N/A.

Additional Information (Optional)

This is the consumer side. The marker files are produced by the companion
sonic-utilities PR; both are required for end-to-end user attribution.

DPU reboot-cause history records written by chassisd hardcoded an empty
'user' field, unlike the NPU flow where the reboot script captures the
operator via logname so 'show reboot-cause history' can attribute
user-initiated reboots/shutdowns.

Populate 'user' from a prev_reboot_user.txt marker that
reboot_smartswitch_helper and 'config chassis modules shutdown'
(sonic-utilities) write before a user-initiated DPU reboot/shutdown.
persist_dpu_reboot_cause() reads the marker via retrieve_dpu_reboot_user()
and removes it after use (one-shot). For hardware/auto-detected reboots no
marker exists, so 'user' defaults to 'N/A', matching the NPU
determine-reboot-cause default and keeping the JSON schema consistent with
process-reboot-cause.

Add unit tests for the populated and 'N/A' cases and for
retrieve_dpu_reboot_user().

Signed-off-by: Vasundhara Volam <vvolam@microsoft.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

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