diff --git a/.github/workflows/kvm-publishable-selfhosted.yml b/.github/workflows/kvm-publishable-selfhosted.yml index b2a44c5..a802f22 100644 --- a/.github/workflows/kvm-publishable-selfhosted.yml +++ b/.github/workflows/kvm-publishable-selfhosted.yml @@ -57,6 +57,9 @@ jobs: if [[ -f /sys/module/kvm_amd/parameters/nested ]]; then echo "kvm_amd_nested=$(cat /sys/module/kvm_amd/parameters/nested)" fi + echo "runner_temp=${RUNNER_TEMP}" + df -h / /tmp /var/tmp "$RUNNER_TEMP" || true + df -h /nix || true - name: Run Publishable KVM Suite run: | diff --git a/nix/test-cluster/run-publishable-kvm-suite.sh b/nix/test-cluster/run-publishable-kvm-suite.sh index 326d79d..0e3b1de 100755 --- a/nix/test-cluster/run-publishable-kvm-suite.sh +++ b/nix/test-cluster/run-publishable-kvm-suite.sh @@ -13,6 +13,27 @@ log() { printf '[publishable-kvm-suite] %s\n' "$*" } +choose_runtime_root() { + local candidate avail best="" best_avail=-1 + + for candidate in /nix/var/tmp /var/tmp /tmp "${HOME}"; do + mkdir -p "${candidate}" 2>/dev/null || continue + avail="$(df -Pk "${candidate}" 2>/dev/null | awk 'NR==2 { print $4 }')" + [[ -n "${avail}" ]] || continue + if (( avail > best_avail )); then + best="${candidate}" + best_avail="${avail}" + fi + done + + [[ -n "${best}" ]] || { + log "no writable runtime root found" + return 1 + } + + printf '%s\n' "${best}/ultracloud-publishable-kvm-suite" +} + get_hostname() { if command -v hostname >/dev/null 2>&1; then hostname @@ -21,6 +42,16 @@ get_hostname() { fi } +prepare_runtime_dirs() { + local runtime_root + + runtime_root="$(choose_runtime_root)" + export ULTRACLOUD_KVM_RUNTIME_ROOT="${runtime_root}" + export TMPDIR="${runtime_root}/tmp" + export XDG_CACHE_HOME="${runtime_root}/xdg-cache" + mkdir -p "${TMPDIR}" "${XDG_CACHE_HOME}" +} + capture_environment() { { printf 'started_at=%s\n' "$(date -Is)" @@ -33,6 +64,9 @@ capture_environment() { printf 'branch=%s\n' "$(git -C "${REPO_ROOT}" branch --show-current)" printf 'commit=%s\n' "$(git -C "${REPO_ROOT}" rev-parse HEAD)" printf 'nix_version=%s\n' "$(nix --version)" + printf 'runtime_root=%s\n' "${ULTRACLOUD_KVM_RUNTIME_ROOT:-}" + printf 'tmpdir=%s\n' "${TMPDIR:-}" + printf 'xdg_cache_home=%s\n' "${XDG_CACHE_HOME:-}" printf 'kvm_present=%s\n' "$([[ -e /dev/kvm ]] && echo yes || echo no)" if [[ -e /dev/kvm ]]; then printf 'kvm_stat=%s\n' "$(stat -c '%A %U %G %t:%T' /dev/kvm)" @@ -79,6 +113,7 @@ run_case() { } main() { + prepare_runtime_dirs capture_environment [[ -e /dev/kvm ]] || {