if [[ ! -z $SSH_KNOWN_HOSTS_FILE ]]; then
SSH_OPTS="$SSH_OPTS -o UserKnownHostsFile=$SSH_KNOWN_HOSTS_FILE"
fi
- timeout ${SSH_TIMEOUT:-"30s"} ssh -i ${SSH_KEY:-"$HOME/.ssh/id_rsa"} $SSH_OPTS ${SSH_USER}@${SSH_ADDRESS} ${@}
+ timeout ${SSH_TIMEOUT:-"30s"} ssh -i ${SSH_KEY:-"$HOME/.ssh/id_rsa"} $SSH_OPTS ${SSH_USER}@${SSH_ADDRESS} ${@} || {
+ EXIT_CODE=$?
+ # By default, the "timeout" CLI tool always exits with 124 when the
+ # timeout is exceeded. Unless "--preserve-status" argument is used, the
+ # exit code is never set to the exit code of the command that timed out.
+ if [[ $EXIT_CODE -eq 124 ]]; then
+ echo "ERROR: ssh command timed out"
+ fi
+ exit $EXIT_CODE
+ }
}
function scp_upload() {
scp_download /ProgramData/ceph/logs $WORKSPACE/artifacts/client/logs
cp $CEPH_WINDOWS_CONF $WORKSPACE/artifacts/client
ssh_exec /wnbd/wnbd-client.exe version
- # Event log collection is temporarily disabled. The script terminates
- # abruptly even if the error action is set to "ignore".
- #
- # ssh_exec curl.exe --retry-max-time 30 --retry 10 -L -o /workspace/collect-event-logs.ps1 $COLLECT_EVENT_LOGS_SCRIPT_URL
- # ssh_exec powershell.exe /workspace/collect-event-logs.ps1 -LogDirectory /workspace/eventlogs
- # scp_download /workspace/eventlogs $WORKSPACE/artifacts/client/eventlogs
+ ssh_exec curl.exe --retry-max-time 30 --retry 10 -L -o /workspace/collect-event-logs.ps1 $COLLECT_EVENT_LOGS_SCRIPT_URL
+ SSH_TIMEOUT=30m ssh_exec powershell.exe /workspace/collect-event-logs.ps1 -LogDirectory /workspace/eventlogs
+ scp_download /workspace/eventlogs $WORKSPACE/artifacts/client/eventlogs
}
trap collect_artifacts EXIT