#!/usr/bin/env bash # Fails a self-hosted job whose workspace, temp or Go cache directory is not # on an NVMe disk. The process-level tests write and fsync real files; on a # box whose system disk is SATA, a default runner install puts _work there and # the tests time out under the disk load instead of failing on a real bug. # A tmpfs directory is accepted (memory, not a slow disk). # Usage: require-nvme.sh DIR... set -euo pipefail bad=0 for p in "$@"; do [ -n "$p" ] || continue d=$p while [ ! -e "$d" ]; do d=$(dirname "$d"); done read -r src fstype < <(df --output=source,fstype "$d" | tail -n 1) if [ "$fstype" = tmpfs ]; then echo "ok $p: $src (tmpfs)" continue fi # Every disk under the source (all members of an array) must be NVMe; an # lsblk error voids whatever it printed. disks= if tree=$(lsblk -nrso TYPE,TRAN "$src" 2>/dev/null); then disks=$(printf '%s\n' "$tree" | awk '$1 == "disk" { print ($2 == "" ? "unknown" : $2) }' | sort -u | tr '\n' ' ') fi if [ "$disks" = "nvme " ]; then echo "ok $p: $src (nvme)" else echo "FAIL $p: $src (disk: ${disks:-not a block device})" bad=1 fi done if [ "$bad" -ne 0 ]; then echo "runner ${RUNNER_NAME:-?}: work, temp and Go cache directories must be on NVMe; move them before this runner takes jobs" >&2 exit 1 fi