From f1de19fc14dbadff0d10982f97df9c4d7c571050 Mon Sep 17 00:00:00 2001 From: hector <42570491+majinghe@users.noreply.github.com> Date: Thu, 27 Aug 2026 19:16:52 +0800 Subject: [PATCH] test: fall back to writable temp files for logs/status in /tmp (#6743) A fixed /tmp path (log file, final heal status, warp log) can be owned by another user on the shared runner (e.g. a previous root run), which made the github-runner user fail: tee could not append the test log, the final heal status write killed step 6 with EACCES, and upload-artifact could not read stale root-owned warp logs. The heal scenario itself had passed (summary=finished, vm002 reached the target) before the status-save died. - Log files fall back to a unique mktemp path when the configured path is not writable (heal + pool scripts). - The final heal status is written to a mktemp file (best effort). - Workflow artifact uploads use globs for the fallback names. --- .github/workflows/rustfs-heal-test.yml | 2 +- .github/workflows/rustfs-pool-expand-test.yml | 2 +- scripts/test/rustfs_heal_test.sh | 12 +++++++++++- scripts/test/rustfs_pool_expand.sh | 6 ++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rustfs-heal-test.yml b/.github/workflows/rustfs-heal-test.yml index 1dc03738a..9f5189257 100644 --- a/.github/workflows/rustfs-heal-test.yml +++ b/.github/workflows/rustfs-heal-test.yml @@ -109,7 +109,7 @@ jobs: with: name: rustfs-heal-test-${{ github.run_id }} path: | - /tmp/rustfs-heal-test.log + /tmp/rustfs-heal-test*.log /tmp/rustfs-warp.*.log if-no-files-found: warn diff --git a/.github/workflows/rustfs-pool-expand-test.yml b/.github/workflows/rustfs-pool-expand-test.yml index 17527d8bf..b95fe8742 100644 --- a/.github/workflows/rustfs-pool-expand-test.yml +++ b/.github/workflows/rustfs-pool-expand-test.yml @@ -154,7 +154,7 @@ jobs: with: name: rustfs-pool-test-${{ github.run_id }} path: | - /tmp/rustfs-pool-test.log + /tmp/rustfs-pool-test*.log /tmp/rustfs-warp.*.log if-no-files-found: warn diff --git a/scripts/test/rustfs_heal_test.sh b/scripts/test/rustfs_heal_test.sh index 4dc848ee6..9c0172085 100755 --- a/scripts/test/rustfs_heal_test.sh +++ b/scripts/test/rustfs_heal_test.sh @@ -900,7 +900,11 @@ step6_monitor_heal() { if printf '%s' "${summary}" | grep -qiE '^(finished|completed|success|done)$' \ && [ "${vm002_used}" -ge "${HEAL_TARGET_GB}" ]; then log "heal done: summary=${summary} failed=0 ${NODES[${OUTAGE_NODE_INDEX}]}_used=${vm002_used}GB >= ${HEAL_TARGET_GB}GB" - printf '%s\n' "${body}" > "${TMPDIR:-/tmp}/rustfs-heal-final-status.json" + final_status_file="$(mktemp "${TMPDIR:-/tmp}/rustfs-heal-final-status.XXXXXX.json" 2>/dev/null \ + || printf '%s' "${TMPDIR:-/tmp}/rustfs-heal-final-status.$$.json")" + printf '%s\n' "${body}" > "${final_status_file}" 2>/dev/null \ + && log "final heal status saved: ${final_status_file}" \ + || warn "could not save final heal status to ${final_status_file}" return 0 fi sleep "${POLL_INTERVAL}" @@ -1068,6 +1072,12 @@ main() { trap 'rm -f "${ADMIN_API_CODE_FILE}"' EXIT if [ -n "${LOG_FILE}" ]; then mkdir -p "$(dirname "${LOG_FILE}")" + if ! touch "${LOG_FILE}" 2>/dev/null; then + # A fixed /tmp path may be owned by another user (e.g. a previous root + # run); fall back to a unique, always-writable temp file. + LOG_FILE="$(mktemp "${TMPDIR:-/tmp}/rustfs-heal-test.XXXXXX.log")" + warn "log file not writable; using ${LOG_FILE}" + fi exec > >(tee -a "${LOG_FILE}") 2>&1 fi if [ "${RESET}" -eq 1 ]; then diff --git a/scripts/test/rustfs_pool_expand.sh b/scripts/test/rustfs_pool_expand.sh index 2f5f744d7..c88935996 100755 --- a/scripts/test/rustfs_pool_expand.sh +++ b/scripts/test/rustfs_pool_expand.sh @@ -1128,6 +1128,12 @@ main() { trap 'rm -f "${ADMIN_API_CODE_FILE}"' EXIT if [ -n "${LOG_FILE}" ]; then mkdir -p "$(dirname "${LOG_FILE}")" + if ! touch "${LOG_FILE}" 2>/dev/null; then + # A fixed /tmp path may be owned by another user (e.g. a previous root + # run); fall back to a unique, always-writable temp file. + LOG_FILE="$(mktemp "${TMPDIR:-/tmp}/rustfs-pool-test.XXXXXX.log")" + warn "log file not writable; using ${LOG_FILE}" + fi exec > >(tee -a "${LOG_FILE}") 2>&1 fi if [ "${RESET}" -eq 1 ]; then