Skip to content

Commit c7b41ac

Browse files
committed
RunCommand to run one command at a time due to return size limitation
1 parent 9190160 commit c7b41ac

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

lisa/features/non_ssh_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ def _execute(self, commands: List[str]) -> List[str]:
4949
for command in commands:
5050
serial_console.write(self._add_newline(command))
5151
out.append(serial_console.read())
52+
return out
5253
except Exception as e:
5354
raise LisaException(f"Failed to execute commands: {e}") from e
5455
finally:
5556
serial_console.close()
56-
return out
5757

5858
def _add_newline(self, command: str) -> str:
5959
"""

lisa/node.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ def check_sudo_password_required(self) -> None:
743743
raise RequireUserPasswordException("Reset password failed")
744744
self._check_password_and_store_prompt()
745745

746-
def _collect_logs_using_non_ssh_executor(self):
746+
def _collect_logs_using_non_ssh_executor(self) -> None:
747747
"""
748748
Collects information using the NonSshExecutor feature.
749749
This is used when the connection to the node is not stable.
@@ -764,9 +764,11 @@ def _collect_logs_using_non_ssh_executor(self):
764764

765765
if self.features.is_supported(NonSshExecutor):
766766
non_ssh_executor = self.features[NonSshExecutor]
767-
out = non_ssh_executor.execute(commands=commands)
768-
out = "\n\n".join(out)
769-
self.log.info(f"Collected information using NonSshExecutor:\n{out}")
767+
outputs = non_ssh_executor.execute(commands=commands)
768+
collected_info = "\n\n".join(outputs)
769+
self.log.info(
770+
f"Collected information using NonSshExecutor:\n{collected_info}"
771+
)
770772
else:
771773
self.log.debug(
772774
f"NonSshExecutor is not supported on {self.name}, "

lisa/sut_orchestrator/azure/features.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3755,7 +3755,7 @@ def execute(self, commands: List[str]) -> str:
37553755
:return: The output of the commands.
37563756
"""
37573757
context = get_node_context(self._node)
3758-
platform = self._platform
3758+
platform: AzurePlatform = self._platform # type: ignore
37593759
compute_client = get_compute_client(platform)
37603760

37613761
# Prepare the RunCommandInput for Azure
@@ -3772,7 +3772,7 @@ def execute(self, commands: List[str]) -> str:
37723772
)
37733773
result = wait_operation(operation=operation, failure_identity="run command")
37743774

3775-
return result["value"][0]["message"]
3775+
return str(result["value"][0]["message"])
37763776

37773777
def _add_echo_before_command(self, commands: List[str]) -> List[str]:
37783778
"""
@@ -3784,10 +3784,14 @@ def _add_echo_before_command(self, commands: List[str]) -> List[str]:
37843784

37853785
class NonSshExecutor(AzureFeatureMixin, features.NonSshExecutor):
37863786
def execute(self, commands: List[str]) -> List[str]:
3787-
# RunCommand is faster than SerialConsole. Hence attempt to use it first.
3787+
# RunCommand does not require password login, hence attempt to use it first.
3788+
# RunCommand has a limitation on 4KB of output.
37883789
try:
3789-
output = self._node.features[RunCommand].execute(commands)
3790-
return [output]
3790+
result = []
3791+
for command in commands:
3792+
out = self._node.features[RunCommand].execute([command])
3793+
result.append(out)
3794+
return result
37913795
except Exception as e:
37923796
self._log.info(f"RunCommand failed: {e}")
37933797
# Fallback to the default non-SSH executor behavior

0 commit comments

Comments
 (0)