mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
Merge pull request #934 from seaweedfs/ci/require-nvme
ci: stop a self-hosted job whose work or temp dir is not on NVMe
This commit is contained in:
commit
1b59e1a371
4 files changed
+99
No files matched your search
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tests require-nvme.sh with df and lsblk replaced by stubs on PATH.
|
||||
set -euo pipefail
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
t=$(mktemp -d)
|
||||
trap 'rm -rf "$t"' EXIT
|
||||
mkdir -p "$t/bin" "$t/nvme" "$t/sata" "$t/mem" "$t/raid" "$t/share" "$t/half"
|
||||
# df --output=source,fstype DIR: the stub answers by the directory's name.
|
||||
cat >"$t/bin/df" <<STUB
|
||||
#!/usr/bin/env bash
|
||||
printf 'Filesystem Type\n'
|
||||
case "\$2" in
|
||||
$t/nvme*) echo '/dev/nvme0n1p1 ext4' ;;
|
||||
$t/mem*) echo 'shm tmpfs' ;;
|
||||
$t/raid*) echo '/dev/md0 ext4' ;;
|
||||
$t/share*) echo '//nas/work cifs' ;;
|
||||
$t/half*) echo '/dev/nvme1n1p1 ext4' ;;
|
||||
*) echo '/dev/sda2 ext4' ;;
|
||||
esac
|
||||
STUB
|
||||
# lsblk -nrso TYPE,TRAN SOURCE: the source and the devices under it.
|
||||
cat >"$t/bin/lsblk" <<'STUB'
|
||||
#!/usr/bin/env bash
|
||||
case "$3" in
|
||||
/dev/nvme0n1p1) printf 'part \ndisk nvme\n' ;;
|
||||
/dev/sda2) printf 'part \ndisk sata\n' ;;
|
||||
/dev/md0) printf 'raid1 \npart \ndisk nvme\npart \ndisk sata\n' ;;
|
||||
/dev/nvme1n1p1) printf 'part \ndisk nvme\n'; echo "lsblk: read error" >&2; exit 32 ;;
|
||||
*) echo "lsblk: $3: not a block device" >&2; exit 32 ;;
|
||||
esac
|
||||
STUB
|
||||
chmod +x "$t/bin/df" "$t/bin/lsblk"
|
||||
run() { PATH="$t/bin:$PATH" RUNNER_NAME=r1 bash "$here/require-nvme.sh" "$@" >"$t/out" 2>&1; }
|
||||
fail() { echo "FAIL: $*"; cat "$t/out"; exit 1; }
|
||||
|
||||
run "$t/nvme" "$t/mem" "" || fail "nvme + tmpfs (any source name) + empty arg must pass"
|
||||
run "$t/nvme/not/made/yet" || fail "a missing dir is judged by its nearest existing parent"
|
||||
! run "$t/nvme" "$t/sata" || fail "a SATA dir must fail"
|
||||
grep -q "runner r1" "$t/out" || fail "the failure must name the runner"
|
||||
grep -q "FAIL $t/sata" "$t/out" || fail "the failure must name the directory"
|
||||
! run "$t/raid" || fail "an array with a SATA member must fail"
|
||||
! run "$t/share" || fail "a network share must fail"
|
||||
grep -q "not a block device" "$t/out" || fail "a network share must say why"
|
||||
! run "$t/half" || fail "an lsblk error after partial NVMe output must fail"
|
||||
echo "require-nvme tests: ok"
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#!/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
|
||||
@@ -27,6 +27,15 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Runner disk is NVMe
|
||||
# A self-hosted runner whose work, temp or Go cache directory sits on a
|
||||
# SATA system disk times the process-level tests out under disk load;
|
||||
# this names the runner and stops the job before it starts.
|
||||
if: runner.environment == 'self-hosted'
|
||||
run: |
|
||||
bash .github/scripts/require-nvme-test.sh
|
||||
bash .github/scripts/require-nvme.sh "$GITHUB_WORKSPACE" "$RUNNER_TEMP" "${TMPDIR:-/tmp}" "${GOCACHE:-$HOME/.cache/go-build}"
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
|
||||
with:
|
||||
|
||||
+9
@@ -55,6 +55,15 @@ jobs:
|
||||
# step can see which packages the PR touches.
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Runner disk is NVMe
|
||||
# A self-hosted runner whose work, temp or Go cache directory sits on a
|
||||
# SATA system disk times the process-level tests out under disk load;
|
||||
# this names the runner and stops the job before it starts.
|
||||
if: runner.environment == 'self-hosted'
|
||||
run: |
|
||||
bash .github/scripts/require-nvme-test.sh
|
||||
bash .github/scripts/require-nvme.sh "$GITHUB_WORKSPACE" "$RUNNER_TEMP" "${TMPDIR:-/tmp}" "${GOCACHE:-$HOME/.cache/go-build}"
|
||||
|
||||
- name: Docs-only pull request
|
||||
id: scope
|
||||
if: matrix.suite == 'process' && github.event_name == 'pull_request'
|
||||
|
||||
Reference in new issue
Block a user