Incident 2026-06-24: OOM-uri repetate în cgroup /lxc/171 cauzate de swap nebacked pe host (pvemini fără swap) + acumulare de forks vscode-server orfane și sesiuni logind zombie. - scripts/reap-orphans.sh: reaping conservator (forks ~/.vscode-server orfane >24h + sesiuni closing cu leader mort), rulat din cron la 6h - README: secțiune Memorie & OOM (zram pe host ZFS, reaper, diagnostic), corectat date stale host/RAM/CPU (pvemini, 16GB, 4 cores) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
53 lines
2.2 KiB
Bash
Executable File
53 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# reap-orphans.sh — curăță procese VS Code Remote-SSH orfane + sesiuni logind zombie.
|
|
#
|
|
# Context: LXC 171 (claude-agent) acumulează forks ~/.vscode-server reparentate la init
|
|
# (conexiunea SSH a murit, dar serverul Remote-SSH rămâne) + sesiuni logind blocate în
|
|
# stare 'closing'. Acestea umplu treptat cgroup-ul de 16GB; împreună cu spike-uri
|
|
# Chromium/Playwright declanșau OOM-kill în /lxc/171 (incident 2026-06-24).
|
|
# zram-ul de pe host absoarbe vârfurile, dar nu oprește acumularea de fond — asta o face.
|
|
#
|
|
# Rulează din cron ca root, ÎN INTERIORUL containerului. Conservator + idempotent.
|
|
#
|
|
# NU atinge:
|
|
# - daemonul de bază /usr/lib/code-server (PPID=1 dar legitim, lansat de ttyd)
|
|
# - procese Claude Code / node de workload (pot fi task-uri lungi legitime)
|
|
# - sesiuni active sau procese cu părinte viu (arborele SSH e intact)
|
|
set -uo pipefail
|
|
|
|
THRESH=${REAP_AGE_SECONDS:-86400} # reape doar orfane mai vechi de 24h
|
|
LOG=${REAP_LOG:-/var/log/reap-orphans.log}
|
|
killed=0
|
|
|
|
log() { echo "[$(date '+%F %T')] $*" >> "$LOG"; }
|
|
|
|
# 1) Forks ~/.vscode-server reparentate la init (PPID=1) și vechi => conexiune SSH moartă
|
|
while read -r pid ppid etimes args; do
|
|
[ "$ppid" = "1" ] || continue
|
|
[ "$etimes" -ge "$THRESH" ] || continue
|
|
case "$args" in
|
|
*/usr/lib/code-server*) continue ;; # daemon de bază — păstrează
|
|
*/.vscode-server/*) : ;; # doar serverele Remote-SSH per-conexiune
|
|
*) continue ;;
|
|
esac
|
|
if kill "$pid" 2>/dev/null; then
|
|
log "killed orphan vscode pid=$pid age=${etimes}s :: ${args:0:90}"
|
|
killed=$((killed + 1))
|
|
fi
|
|
done < <(ps -eo pid,ppid,etimes,args --no-headers)
|
|
|
|
# 2) Sesiuni logind 'closing' cu leader mort (leader=0) => zombi siguri de terminat
|
|
for s in $(loginctl list-sessions --no-legend 2>/dev/null | awk '{print $1}'); do
|
|
st=$(loginctl show-session "$s" -p State --value 2>/dev/null)
|
|
lp=$(loginctl show-session "$s" -p Leader --value 2>/dev/null)
|
|
if [ "$st" = "closing" ] && [ "$lp" = "0" ]; then
|
|
if loginctl terminate-session "$s" 2>/dev/null; then
|
|
log "terminated zombie session $s"
|
|
killed=$((killed + 1))
|
|
fi
|
|
fi
|
|
done
|
|
|
|
[ "$killed" -gt 0 ] && log "reaped $killed item(s)"
|
|
exit 0
|