]> git.apps.os.sepia.ceph.com Git - ceph-build.git/commitdiff
ceph-windows: Enable Windows event log collection 2116/head
authorIonut Balutoiu <ibalutoiu@cloudbasesolutions.com>
Thu, 16 Feb 2023 17:43:13 +0000 (19:43 +0200)
committerIonut Balutoiu <ibalutoiu@cloudbasesolutions.com>
Thu, 16 Feb 2023 17:43:58 +0000 (19:43 +0200)
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 <ibalutoiu@cloudbasesolutions.com>
scripts/build_utils.sh
scripts/ceph-windows/run_tests

index d22328b42d64e8a1b56bf661d1f5a5678fd0e953..d898a41396156a5ade5987bcfc69a3369502f316 100755 (executable)
@@ -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() {
index 96117660f1e741070a3fbc609d0f94801a551749..56543d81cca9061a4d274ca970248a77ca4d13a8 100644 (file)
@@ -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