Conversation
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>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Description
DPU reboot-cause history records written by
chassisdhardcoded the dict inpersist_dpu_reboot_cause()without auserkey, so whenupdate_dpu_reboot_cause_to_db()deletes and rewrites theREBOOT_CAUSE|DPU<N>|*keys inCHASSIS_STATE_DB, theuserfielddisappeared — diverging from
process-reboot-cause(sonic-host-services),which always writes
user.This change:
userfield to the persisted DPU reboot-cause record.reboot/shutdown, read from a one-shot marker
/host/reboot-cause/module/<dpu>/prev_reboot_user.txtwritten by thesonic-utilities producers (
reboot_smartswitch_helperandconfig chassis modules shutdown— see companion PR). chassisd reads themarker via
retrieve_dpu_reboot_user()and removes it after use.usertoN/Afor hardware/auto-detected reboots where nomarker exists, matching the NPU
determine-reboot-causedefault and keepingthe 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
chassisdomitted theuserfieldwhen rewriting
CHASSIS_STATE_DB. Beyond just restoring schema parity, thisattributes user-initiated DPU reboots/shutdowns, mirroring the NPU
reboot-cause
userfield shown byshow 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-chassisdsuite passes (53 tests). New/updated cases:test_persist_dpu_reboot_cause_includes_user_field—userpresent, defaults toN/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/Awhen empty/missing.Manual (SmartSwitch DUT):
reboot -d DPU0) or shutdown (config chassis modules shutdown DPU0).redis-cli -h redis_chassis.server -p 6380 -n 13 HGETALL "REBOOT_CAUSE|DPU0|<name>"→user= operator.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.