[chassis] Record operator for user-initiated DPU reboot/shutdown#4653
Draft
vvolam wants to merge 1 commit into
Draft
[chassis] Record operator for user-initiated DPU reboot/shutdown#4653vvolam wants to merge 1 commit into
vvolam wants to merge 1 commit into
Conversation
DPU down events triggered by an operator did not capture who issued them,
so the DPU reboot-cause history (written by chassisd) showed no 'user',
unlike the NPU reboot-cause flow where the reboot script records logname.
Persist the operator to /host/reboot-cause/module/<dpu>/prev_reboot_user.txt
before a user-initiated DPU goes down, so chassisd can read and clear the
marker to populate the reboot-cause 'user' field:
- reboot_smartswitch_helper: write REBOOT_USER (from the sourcing reboot
script, falling back to logname/whoami) in reboot_dpu(), covering both the
single-DPU ('-d') and all-DPU SmartSwitch paths.
- config chassis modules shutdown: write the operator (SUDO_USER, falling
back to getpass) in shutdown_chassis_module() for the SmartSwitch DPU
branch. Best-effort: a marker-write failure never blocks the shutdown.
Hardware/auto-detected reboots write no marker, so chassisd reports 'N/A'.
Add unit tests for the shutdown user capture and for persist_dpu_reboot_user.
Signed-off-by: Vasundhara Volam <vvolam@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
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
Capture the operator who triggers a user-initiated DPU down event so the
DPU reboot-cause history (written by
chassisd) can attribute it, mirroringthe NPU reboot-cause
userfield. Covers both DPU down paths:reboot_smartswitch_helperconfig chassis modules shutdown <DPU>Companion consumer PR in sonic-platform-daemons (chassisd reads the marker and
populates the
userfield): sonic-net/sonic-platform-daemons#841Addresses sonic-net/sonic-buildimage#28149.
How I did it
Both producers write the operator to
/host/reboot-cause/module/<dpu>/prev_reboot_user.txtbefore the DPU goesdown; chassisd reads and clears this one-shot marker.
scripts/reboot_smartswitch_helper: writeREBOOT_USER(exported by thesourcing
rebootscript vialogname, falling back towhoami) inreboot_dpu(), so both the single-DPU (-d) and all-DPU SmartSwitch pathsare covered.
config/chassis_modules.py:persist_dpu_reboot_user()writes the operator(
SUDO_USER, falling back togetpass.getuser()) and is called inshutdown_chassis_module()for the SmartSwitch DPU branch. It isbest-effort — a marker-write failure logs a warning and never blocks the
shutdown. Hardware/auto reboots write no marker, so chassisd reports
N/A.How to verify it
Unit tests:
tests/chassis_modules_test.py::test_persist_dpu_reboot_user— writes themarker with
SUDO_USER.test_shutdown_smartswitch_module— assertspersist_dpu_reboot_user("DPU0")is invoked on shutdown.
Manual (SmartSwitch DUT):
config chassis modules shutdown DPU0(orreboot -d DPU0).cat /host/reboot-cause/module/dpu0/prev_reboot_user.txt→ operator name.redis-cli -h redis_chassis.server -p 6380 -n 13 HGETALL "REBOOT_CAUSE|DPU0|<name>"and
show reboot-cause history DPU0→Usercolumn shows the operator.Previous command output (if the output of a command-line utility has changed)
No CLI output change.
config chassis modules shutdown DPU0still printsShutting down chassis module DPU0. The captured operator surfaces only inshow reboot-cause history <DPU>once chassisd persists the record.New command output (if the output of a command-line utility has changed)
N/A — no command output changed; only the recorded reboot-cause
userfield.