From 2222d4bdd3ad3f9579ac7c7d11708d3f93c1f0c0 Mon Sep 17 00:00:00 2001 From: Ionut Balutoiu Date: Thu, 16 Feb 2023 19:43:13 +0200 Subject: [PATCH] ceph-windows: Enable Windows event log collection The Windows event log collection was failing due `ssh_exec` abruptly closing the connection, because the default timeout of `30 secs` was exceeded. This change re-enables the Windows event log collection by increasing the SSH timeout to `30 minutes`. Additionally, the `ssh_exec` function is updated to print an appropriate error message when SSH timeout is exceeded. Signed-off-by: Ionut Balutoiu --- scripts/build_utils.sh | 11 ++++++++++- scripts/ceph-windows/run_tests | 9 +++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/build_utils.sh b/scripts/build_utils.sh index d22328b4..d898a413 100755 --- a/scripts/build_utils.sh +++ b/scripts/build_utils.sh @@ -1682,7 +1682,16 @@ function ssh_exec() { 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() { diff --git a/scripts/ceph-windows/run_tests b/scripts/ceph-windows/run_tests index 96117660..56543d81 100644 --- a/scripts/ceph-windows/run_tests +++ b/scripts/ceph-windows/run_tests @@ -76,12 +76,9 @@ function collect_artifacts() { 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 -- 2.39.5