Merge "Acloud create: record the instance name in report for all kinds of exceptions."
diff --git a/internal/lib/cvd_compute_client_multi_stage.py b/internal/lib/cvd_compute_client_multi_stage.py
index 46b4e6b..df1fb26 100644
--- a/internal/lib/cvd_compute_client_multi_stage.py
+++ b/internal/lib/cvd_compute_client_multi_stage.py
@@ -70,6 +70,7 @@
_START_WEBRTC = "--start_webrtc"
_VM_MANAGER = "--vm_manager=crosvm"
_WEBRTC_ARGS = [_GUEST_ENFORCE_SECURITY_FALSE, _START_WEBRTC, _VM_MANAGER]
+_NO_RETRY = 0
def _ProcessBuild(build_id=None, branch=None, build_target=None):
@@ -375,7 +376,7 @@
boot_timeout_secs = boot_timeout_secs or constants.DEFAULT_CF_BOOT_TIMEOUT
ssh_command = "./bin/launch_cvd -daemon " + " ".join(launch_cvd_args)
try:
- self._ssh.Run(ssh_command, boot_timeout_secs)
+ self._ssh.Run(ssh_command, boot_timeout_secs, retry=_NO_RETRY)
except (subprocess.CalledProcessError, errors.DeviceConnectionError) as e:
# TODO(b/140475060): Distinguish the error is command return error
# or timeout error.
diff --git a/internal/lib/ssh.py b/internal/lib/ssh.py
index 4e0da20..6dce93f 100755
--- a/internal/lib/ssh.py
+++ b/internal/lib/ssh.py
@@ -130,7 +130,8 @@
raise subprocess.CalledProcessError(process.returncode, cmd)
-def ShellCmdWithRetry(cmd, timeout=None, show_output=False):
+def ShellCmdWithRetry(cmd, timeout=None, show_output=False,
+ retry=_SSH_CMD_MAX_RETRY):
"""Runs a shell command on remote device.
If the network is unstable and causes SSH connect fail, it will retry. When
@@ -142,14 +143,15 @@
cmd: String of the full SSH command to run, including the SSH binary and its arguments.
timeout: Optional integer, number of seconds to give.
show_output: Boolean, True to show command output in screen.
+ retry: Integer, the retry times.
Raises:
errors.DeviceConnectionError: For any non-zero return code of
remote_cmd.
"""
utils.RetryExceptionType(
- exception_types=errors.DeviceConnectionError,
- max_retries=_SSH_CMD_MAX_RETRY,
+ exception_types=(errors.DeviceConnectionError, subprocess.CalledProcessError),
+ max_retries=retry,
functor=_SshLogOutput,
sleep_multiplier=_SSH_CMD_RETRY_SLEEP,
retry_backoff_factor=utils.DEFAULT_RETRY_BACKOFF_FACTOR,
@@ -188,7 +190,8 @@
self._ssh_private_key_path = ssh_private_key_path
self._extra_args_ssh_tunnel = extra_args_ssh_tunnel
- def Run(self, target_command, timeout=None, show_output=False):
+ def Run(self, target_command, timeout=None, show_output=False,
+ retry=_SSH_CMD_MAX_RETRY):
"""Run a shell command over SSH on a remote instance.
Example:
@@ -203,10 +206,12 @@
target_command: String, text of command to run on the remote instance.
timeout: Integer, the maximum time to wait for the command to respond.
show_output: Boolean, True to show command output in screen.
+ retry: Integer, the retry times.
"""
ShellCmdWithRetry(self.GetBaseCmd(constants.SSH_BIN) + " " + target_command,
timeout,
- show_output)
+ show_output,
+ retry)
def GetBaseCmd(self, execute_bin):
"""Get a base command over SSH on a remote instance.