Merge pull request #182 from kevinveenbirkenbach/fix/web-app-peertube/oom/162

Fix peertube OOM during auth-openid-connect plugin install (#162)
This commit is contained in:
kevinveenbirkenbach authored and GitHub committed 2026-04-21 09:05:31 +02:00
commit cc5d4e6d54
32 files changed
+1783 -89

No files matched your search

+92
View File
@@ -0,0 +1,92 @@
#!/usr/bin/env bash
# Dump disk, memory, swap and docker state of a GitHub-hosted runner.
# Intended as a diagnostic helper that can be called from anywhere
# inside a workflow step (pre/post swap resize, post-deploy failure).
#
# Usage: dump_runner_state.sh [label]
# The label is rendered into the log group title and the step summary.
set -euo pipefail
LABEL="${1:-runner state}"
echo "::group::Runner state — ${LABEL}"
echo "--- date ---"
date -u +'%Y-%m-%dT%H:%M:%SZ'
echo "--- disk (bytes) ---"
df -h / /mnt 2>/dev/null || df -h /
echo "--- disk (inodes) ---"
df -hi / /mnt 2>/dev/null || df -hi /
echo "--- block devices ---"
lsblk -f || true
echo "--- mounts (/, /mnt, /var/lib/docker, /mnt/docker) ---"
mount | grep -E ' / | /mnt | /var/lib/docker | /mnt/docker ' || true
echo "--- docker ---"
docker info 2>/dev/null |
grep -E 'Docker Root Dir|Storage Driver|Containers|Images' ||
echo "docker daemon not reachable"
echo "--- memory ---"
free -h
echo "--- swap ---"
swapon --show || echo "no swap active"
echo "--- largest dirs on / (top 15) ---"
sudo du -xh --max-depth=2 / 2>/dev/null | sort -h | tail -15 || true
if [ -d /mnt ]; then
echo "--- largest dirs on /mnt (top 15) ---"
sudo du -xh --max-depth=2 /mnt 2>/dev/null | sort -h | tail -15 || true
fi
# Nested view — hlth-disc-space runs INSIDE the infinito container and
# evaluates df there, so host-side df alone can be misleading. These
# blocks silently no-op when the container is not (yet) running.
echo "--- infinito container (nested view) ---"
INFINITO_CONTAINER="$(docker ps --filter 'name=infinito_nexus' --format '{{.Names}}' 2>/dev/null | head -1 || true)"
if [ -n "${INFINITO_CONTAINER}" ]; then
echo "container: ${INFINITO_CONTAINER}"
echo "--- df inside container ---"
docker exec "${INFINITO_CONTAINER}" df -h 2>&1 || echo "docker exec df failed"
echo "--- df --output=pcent inside container (what hlth-disc-space sees) ---"
docker exec "${INFINITO_CONTAINER}" df --output=pcent 2>&1 || true
echo "--- failed systemd units inside container ---"
docker exec "${INFINITO_CONTAINER}" systemctl --failed --no-pager 2>&1 ||
echo "systemctl --failed not reachable"
echo "--- hlth-disc-space status ---"
docker exec "${INFINITO_CONTAINER}" \
systemctl status 'hlth-disc-space*' --no-pager -l 2>&1 ||
echo "no hlth-disc-space unit (not deployed yet)"
echo "--- hlth-disc-space journal (last 80 lines) ---"
docker exec "${INFINITO_CONTAINER}" \
journalctl -u 'hlth-disc-space*' -n 80 --no-pager 2>&1 ||
echo "journal for hlth-disc-space not accessible"
else
echo "no infinito container running (expected before 'make up')"
fi
echo "::endgroup::"
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
root_free=$(df --output=avail -B1G / 2>/dev/null | tail -n1 | tr -d ' ' || echo '?')
mnt_free=$(df --output=avail -B1G /mnt 2>/dev/null | tail -n1 | tr -d ' ' || echo '?')
mem_free=$(free -g | awk '/^Mem:/ {print $4"G"}')
swap_total=$(free -g | awk '/^Swap:/ {print $2"G"}')
{
echo "### Runner state — ${LABEL}"
echo "- / free: **${root_free}G** · /mnt free: **${mnt_free}G**"
echo "- mem free: **${mem_free}** · swap total: **${swap_total}**"
} >>"$GITHUB_STEP_SUMMARY"
fi
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
# Enlarge host swap on a GitHub-hosted runner. Replaces the runner's
# default ~4 GB swap with a fixed-size swapfile so transient memory
# spikes (e.g. peertube plugin install, issue #162) don't trip the host
# OOM-killer, WITHOUT starving the rest of the job of disk space.
#
# Prefers /mnt when it is a separate partition (classic ubuntu-latest
# layout with /dev/sdb mounted at /mnt). On current public runners
# there is no separate /mnt partition — everything lives on /, so we
# place the swapfile there. The swap size is a hard constant, never a
# "free minus buffer" computation: a previous version consumed ~99 GB
# on a 145 GB root, leaving so little headroom that later Docker layer
# writes (Playwright test image pull) failed with ENOSPC. See #162.
#
# Usage: enlarge_swap.sh [size-gb]
# Default: 16 GB (empirically sufficient for the peertube spike).
#
# Debug toggle: set SKIP_SWAP=1 to leave the runner's default swap
# untouched (A/B probe for issues caused by this script itself).
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DUMP="${HERE}/dump_runner_state.sh"
if [ "${SKIP_SWAP:-0}" = "1" ]; then
echo "SKIP_SWAP=1 — leaving default runner swap in place."
"$DUMP" "skip-swap (SKIP_SWAP=1)"
exit 0
fi
SWAP_GB="${1:-16}"
MIN_FREE_GB=$((SWAP_GB + 4)) # need the target size plus a little slack
"$DUMP" "before swap resize"
sudo swapoff -a || true
sudo rm -f /mnt/swapfile /swapfile
# Only treat /mnt as a candidate if it is actually a separate mount.
# On current ubuntu-latest public runners /mnt is an empty directory
# on the root fs, which would double-count free space.
if mountpoint -q /mnt 2>/dev/null; then
mnt_free=$(df --output=avail -B1G /mnt | tail -n1 | tr -d ' ')
else
mnt_free=0
fi
root_free=$(df --output=avail -B1G / | tail -n1 | tr -d ' ')
echo "Target swap: ${SWAP_GB}G. Free: / ${root_free}G, /mnt ${mnt_free}G (separate mount: $(mountpoint -q /mnt 2>/dev/null && echo yes || echo no))"
if [ "$mnt_free" -ge "$MIN_FREE_GB" ]; then
target=/mnt/swapfile
chosen="/mnt (separate partition)"
elif [ "$root_free" -ge "$MIN_FREE_GB" ]; then
target=/swapfile
chosen="/ (no separate /mnt)"
else
echo "Neither / nor /mnt has ${MIN_FREE_GB} GB free for a ${SWAP_GB} GB swapfile" >&2
df -h / /mnt >&2
exit 1
fi
echo "Chose ${chosen}: creating ${SWAP_GB}G swapfile at ${target}"
sudo fallocate -l "${SWAP_GB}G" "$target"
sudo chmod 600 "$target"
sudo mkswap "$target"
sudo swapon "$target"
"$DUMP" "after swap resize → ${SWAP_GB}G at ${target}"