Skip to content

Collect log using SerialConsole when SshShell fails to connect #3845

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

adityagesh
Copy link
Collaborator

@adityagesh adityagesh commented Jun 5, 2025

ssh may not succeed due to multiple reasons, at present if ssh fails it is either very difficult or impossible to triage the issue without reproducing it.
This change uses NonSshExecutor to run commands for log collection.

ssh may not succeed due to many reasons, at present if ssh fails
it is either very difficult or impossible to triage the issue without
reproducing it.
This change uses SerialConsole to run commands for log collection.
@adityagesh
Copy link
Collaborator Author

@squirrelsc @LiliDeng , this PR is for early design review.

This will enhance triaging of failures for both engineers and AI


# Prepare the RunCommandInput for Azure
command = RunCommandInput(
command_id="RunShellScript",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this Linux specific? Consider whether you can add support for Windows. If not possible, think about how to exclude the Feature for non-Posix systems.

@adityagesh adityagesh force-pushed the aditya/serial_log_after_test_failure branch from 5a994dd to ff40ee5 Compare July 7, 2025 10:15
@adityagesh adityagesh force-pushed the aditya/serial_log_after_test_failure branch from ff40ee5 to bc92811 Compare July 7, 2025 10:15
@adityagesh adityagesh force-pushed the aditya/serial_log_after_test_failure branch from df59804 to a69b551 Compare July 8, 2025 09:17
@adityagesh adityagesh marked this pull request as draft July 8, 2025 09:23
Introduce NonSshExecutor.
It Internally uses SerialConsole/RunCommand
@adityagesh adityagesh force-pushed the aditya/serial_log_after_test_failure branch from a69b551 to 84d4f4a Compare July 8, 2025 09:50
@adityagesh adityagesh force-pushed the aditya/serial_log_after_test_failure branch from ed1e6f5 to 741e95e Compare July 14, 2025 10:04
@adityagesh adityagesh force-pushed the aditya/serial_log_after_test_failure branch from 741e95e to 4ff4695 Compare July 14, 2025 10:21
out = []

serial_console = self._node.features[SerialConsole]
if not serial_console.enabled():
Copy link
Member

Choose a reason for hiding this comment

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

use self._node.features.is_supported to check the feature is available or not before self._node.features[SerialConsole]

lisa/node.py Outdated
f"NonSshExecutor is not supported on {self.name}, "
"cannot collect logs using non-ssh executor."
)
return None
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't need to return None at the end.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My bad, I wasn't thinking straight

@adityagesh adityagesh force-pushed the aditya/serial_log_after_test_failure branch from 4ff4695 to e033ae1 Compare July 14, 2025 15:01
@adityagesh
Copy link
Collaborator Author

adityagesh commented Jul 14, 2025

Testing with non-Linux environments are pending.
I will test with one Windows and Freebsd image.

_ = serial_console.read()
for command in commands:
serial_console.write(self._add_newline(command))
out.append(serial_console.read())
Copy link
Member

Choose a reason for hiding this comment

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

read() may not get all output. How about use previous _ = serial_console.read() to get prompt, and check if the prompt is printed out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense, added logic

    serial_console.write("\n")
    response = serial_console.read()
    if not response or "$" not in response and "#" not in response:

Do you recommend the above or response.strip().endswith()?

_ = serial_console.read()
for command in commands:
serial_console.write(self._add_newline(command))
out.append(serial_console.read())
Copy link
Member

Choose a reason for hiding this comment

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

besides return the output, also printed them out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

def _collect_logs_using_non_ssh_executor (the caller) is currently printing it.

Should I add an optional argument to print it in this function itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants