Skip to content

Commit ff40ee5

Browse files
committed
Remove serial console log collection for network failure
1 parent a4b6e75 commit ff40ee5

File tree

2 files changed

+31
-53
lines changed

2 files changed

+31
-53
lines changed

lisa/node.py

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -694,29 +694,9 @@ def _initialize(self, *args: Any, **kwargs: Any) -> None:
694694
try:
695695
super()._initialize(*args, **kwargs)
696696
except TcpConnectionException as e:
697-
from lisa.features.run_command import RunCommand
698-
699-
run_command = self.features[RunCommand]
700-
commands = [
701-
"echo 'Executing: ip addr show'",
702-
"ip addr show",
703-
"echo 'Executing: ip link show'",
704-
"ip link show",
705-
"echo 'Executing: systemctl status NetworkManager --no-pager --plain'",
706-
"systemctl status NetworkManager --no-pager --plain",
707-
"echo 'Executing: systemctl status network --no-pager --plain'",
708-
"systemctl status network --no-pager --plain",
709-
"echo 'Executing: systemctl status systemd-networkd --no-pager --plain'",
710-
"systemctl status systemd-networkd --no-pager --plain",
711-
"echo 'Executing: ping -c 3 -n 8.8.8.8'",
712-
"ping -c 3 -n 8.8.8.8",
713-
]
714-
out = run_command.execute(commands=commands)
715-
self.log.info(f"Collected information using run_command:\n{out}")
716-
self._login_to_serial_console()
717-
output = self._collect_info_using_serial_console(commands=commands)
718-
self.log.info(f"Collected information using serial console:\n{output}")
719-
697+
vm_logs = self._collect_logs_using_platform()
698+
if vm_logs:
699+
self.log.info(f"Collected information using platform:\n{vm_logs}")
720700
raise e
721701

722702
def get_working_path(self) -> PurePath:
@@ -761,6 +741,33 @@ def check_sudo_password_required(self) -> None:
761741
raise RequireUserPasswordException("Reset password failed")
762742
self._check_password_and_store_prompt()
763743

744+
def _collect_logs_using_platform(self) -> Optional[str]:
745+
"""
746+
Collects information using the RunCommand feature.
747+
This is used when the connection to the node is not stable.
748+
"""
749+
from lisa.features import RunCommand
750+
751+
if self.features.is_supported(RunCommand):
752+
run_command = self.features[RunCommand]
753+
commands = [
754+
"echo 'Executing: ip addr show'",
755+
"ip addr show",
756+
"echo 'Executing: ip link show'",
757+
"ip link show",
758+
"echo 'Executing: systemctl status NetworkManager --no-pager --plain'",
759+
"systemctl status NetworkManager --no-pager --plain",
760+
"echo 'Executing: systemctl status network --no-pager --plain'",
761+
"systemctl status network --no-pager --plain",
762+
"echo 'Executing: systemctl status systemd-networkd --no-pager --plain'",
763+
"systemctl status systemd-networkd --no-pager --plain",
764+
"echo 'Executing: ping -c 3 -n 8.8.8.8'",
765+
"ping -c 3 -n 8.8.8.8",
766+
]
767+
out = run_command.execute(commands=commands)
768+
return out
769+
return None
770+
764771
def _check_password_and_store_prompt(self) -> None:
765772
# self.shell.is_sudo_required_password is true, so running sudo command
766773
# will input password in process.wait_result. Check running sudo again
@@ -830,32 +837,6 @@ def _login_to_serial_console(self) -> None:
830837
"No login prompt found, serial console is already logged in."
831838
)
832839

833-
def _collect_info_using_serial_console(self, commands: List[str]) -> str:
834-
from lisa.features import SerialConsole
835-
836-
if self.features.is_supported(SerialConsole):
837-
serial_console = self.features[SerialConsole]
838-
# clear the serial console
839-
_ = serial_console.read()
840-
commands = [
841-
f"echo 'Executing: {cmd}' && {cmd}"
842-
for cmd in [
843-
"ip addr show",
844-
"ip link show",
845-
"systemctl status NetworkManager --no-pager --plain",
846-
"systemctl status network --no-pager --plain",
847-
"systemctl status systemd-networkd --no-pager --plain",
848-
"ping -c 3 -n 8.8.8.8",
849-
]
850-
]
851-
serial_console.write(data=commands)
852-
output = serial_console.read()
853-
return output
854-
else:
855-
raise LisaException(
856-
"SerialConsole feature is not supported, cannot collect information."
857-
)
858-
859840
def _get_password(self, generate: bool = True) -> str:
860841
"""
861842
Get the password for the node. If the password is not set, it will

lisa/sut_orchestrator/azure/features.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,9 @@ def create_setting(
333333
return schema.FeatureSettings.create(cls.name())
334334

335335
@retry(tries=3, delay=5)
336-
def write(self, data: str | List[str]) -> None:
336+
def write(self, data: str) -> None:
337337
# websocket connection is not stable, so we need to retry
338338
try:
339-
if isinstance(data, list):
340-
# if data is a list, join it with \n and add a newline to the last item
341-
data = "\n".join(data) + "\n"
342339
self._write(data)
343340
return
344341
except websockets.ConnectionClosed as e: # type: ignore

0 commit comments

Comments
 (0)