mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
Add more debugging by re-running ssh commands that failed verbosely.
This CL changes remote_ssh to re-run the command verbosely if the command failed with an SSH error (code 255). BUG=chromium-os:19198 TEST=Ran it. Simulated SSH error by closing KVM instance in cros_run_vm_update while it was intiializing. Saw re-run verbosely run correctly. Change-Id: I9f95aac3fb2d00bc7d26b0b9298409d8ce2db594 Reviewed-on: http://gerrit.chromium.org/gerrit/8313 Commit-Ready: Chris Sosa <sosa@chromium.org> Reviewed-by: Chris Sosa <sosa@chromium.org> Tested-by: Chris Sosa <sosa@chromium.org>
This commit is contained in:
parent
94717e3099
commit
faeee5f47c
@ -30,13 +30,33 @@ function remote_rsync_from() {
|
|||||||
--no-R --files-from=$1 root@${FLAGS_remote}:/ $2
|
--no-R --files-from=$1 root@${FLAGS_remote}:/ $2
|
||||||
}
|
}
|
||||||
|
|
||||||
function remote_sh() {
|
function _verbose_remote_sh() {
|
||||||
|
REMOTE_OUT=$(ssh -vp ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \
|
||||||
|
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -o ConnectTimeout=120 \
|
||||||
|
-i $TMP_PRIVATE_KEY root@$FLAGS_remote "$@")
|
||||||
|
return ${PIPESTATUS[0]}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _non_verbose_remote_sh() {
|
||||||
REMOTE_OUT=$(ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \
|
REMOTE_OUT=$(ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \
|
||||||
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -o ConnectTimeout=120 \
|
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -o ConnectTimeout=120 \
|
||||||
-i $TMP_PRIVATE_KEY root@$FLAGS_remote "$@")
|
-i $TMP_PRIVATE_KEY root@$FLAGS_remote "$@")
|
||||||
return ${PIPESTATUS[0]}
|
return ${PIPESTATUS[0]}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Wrapper for ssh that runs the commmand given by the args on the remote host
|
||||||
|
# If an ssh error occurs, re-runs the ssh command with verbose flag set.
|
||||||
|
function remote_sh() {
|
||||||
|
local ssh_status=0
|
||||||
|
_non_verbose_remote_sh "$@" || ssh_status=$?
|
||||||
|
# 255 indicates an ssh error.
|
||||||
|
if [ ${ssh_status} -eq 255 ]; then
|
||||||
|
_verbose_remote_sh "$@"
|
||||||
|
else
|
||||||
|
return ${ssh_status}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function remote_sh_raw() {
|
function remote_sh_raw() {
|
||||||
ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \
|
ssh -p ${FLAGS_ssh_port} -o StrictHostKeyChecking=no \
|
||||||
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -o ConnectTimeout=120 \
|
-o UserKnownHostsFile=$TMP_KNOWN_HOSTS -o ConnectTimeout=120 \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user