Skip to content

[smartswitch]: Use reboot_gracefully() to record DPU reboot time at command invocation#4571

Open
vvolam wants to merge 2 commits into
sonic-net:masterfrom
vvolam:reboot-gracefully-call
Open

[smartswitch]: Use reboot_gracefully() to record DPU reboot time at command invocation#4571
vvolam wants to merge 2 commits into
sonic-net:masterfrom
vvolam:reboot-gracefully-call

Conversation

@vvolam
Copy link
Copy Markdown
Contributor

@vvolam vvolam commented May 28, 2026

What I did

Updated ModuleHelper.reboot_module() to call reboot_gracefully() (when available) instead of reboot() directly. This ensures prev_reboot_time.txt is written at the moment the user issues reboot -d DPUx, before any race with config reload or chassisd restart.

Fixes: sonic-net/sonic-buildimage#24275

How I did it

In utilities_common/module.py, the reboot_module() method now:

  1. Checks if the platform module exposes reboot_gracefully() (introduced in [smartswitch] Record DPU reboot time at command invocation sonic-platform-common#680).
  2. If available, calls reboot_gracefully(reboot_type) which records the reboot timestamp then delegates to reboot().
  3. Falls back to reboot(reboot_type) for platforms that have not yet picked up the new method.

How to verify it

  1. On a SmartSwitch with sonic-platform-common including [smartswitch] Record DPU reboot time at command invocation sonic-platform-common#680:
    sudo reboot -d DPU0
    
  2. Verify /host/reboot-cause/module/DPU0/prev_reboot_time.txt is created immediately.
  3. Issue config reload right after — the reboot time file should persist and not be lost.
  4. On a platform without reboot_gracefully(), verify reboot -d DPU0 still works via the fallback path.

Previous command output (if the output of a command-line utility has changed)

N/A — no CLI output changes.

New command output (if the output of a command-line utility has changed)

N/A — no CLI output changes.


Related PRs:

Copilot AI review requested due to automatic review settings May 28, 2026 16:55
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates module reboot handling so DPU reboot time can be recorded at command invocation when the platform exposes the newer graceful reboot API, while preserving compatibility with older platform implementations.

Changes:

  • Caches the resolved platform module object before reboot handling.
  • Prefers reboot_gracefully(reboot_type) when available.
  • Falls back to the existing reboot(reboot_type) path otherwise.

Comment thread utilities_common/module.py
@vvolam vvolam changed the title [module]: Use reboot_gracefully() to record DPU reboot time at command invocation [smartswitch]: Use reboot_gracefully() to record DPU reboot time at command invocation May 28, 2026
…d invocation

Signed-off-by: Vasundhara Volam <vvolam@microsoft.com>
@vvolam vvolam force-pushed the reboot-gracefully-call branch from ae89dc1 to 410a25f Compare May 28, 2026 17:07
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@vvolam vvolam requested a review from Copilot May 28, 2026 17:07
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

The new reboot_gracefully tests modify module_helper.platform_chassis
which persisted to subsequent tests (test_module_pre_shutdown_success,
test_module_post_startup_success) causing them to fail.

Fix by adding an autouse fixture that saves and restores
module_helper.platform_chassis between tests.

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.

Bug:[Smartswitch] DPU reboot cause is not updated if reboot is ongoing and config reload is executed

3 participants