Skip to content

Systemctl Tool: Collect debug logs if service fails to start/restart #3911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2025

Conversation

adityagesh
Copy link
Collaborator

@adityagesh adityagesh commented Jul 7, 2025

Collection of additional logs when service fails will reduce the need for repro creation.

@adityagesh adityagesh force-pushed the aditya/debug_systemctl branch from 4a7c4a2 to 25b3257 Compare July 7, 2025 09:43
@LiliDeng LiliDeng requested a review from Copilot July 8, 2025 02:57
Copy link
Contributor

@Copilot 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

Adds automatic collection of debug logs (systemctl status, journalctl, dmesg) when a service start or restart operation fails.

  • Imported Dmesg and Journalctl tools.
  • Enhanced restart_service and start_service to call _collect_logs on non-zero exit codes.
  • Introduced a new _collect_logs method to gather and log relevant system output.
Comments suppressed due to low confidence (3)

lisa/base_tools/service.py:225

  • Add an integration or end-to-end test to verify that failures in start_service and restart_service correctly invoke _collect_logs and log journal and dmesg outputs.
    def _collect_logs(self, service_name: str, operation: str) -> None:

lisa/base_tools/service.py:54

  • Remove the redundant wrapper method for start_service defined at lines 54-56, as it is shadowed by the later implementation that includes log collection.
    def start_service(self, name: str, ignore_exit_code: int = 0) -> None:

lisa/base_tools/service.py:151

  • The call to _check_error_codes is indented inside the if block, so it only runs on failure; it should be dedented to always execute after capturing logs.
        _check_error_codes(cmd_result, ignore_exit_code)

@adityagesh adityagesh force-pushed the aditya/debug_systemctl branch from a0dcafd to 356ba2e Compare July 8, 2025 06:40
@adityagesh adityagesh changed the title Systemctl Tool: Collect debug logs if service fails Systemctl Tool: Collect debug logs if service fails to start/restart Jul 8, 2025
@squirrelsc
Copy link
Member

@LiliDeng LGTM

@LiliDeng LiliDeng merged commit 56b959d into main Jul 10, 2025
53 checks passed
@LiliDeng LiliDeng deleted the aditya/debug_systemctl branch July 10, 2025 12:24
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.

3 participants