feat: self-heal control-plane disk pressure
Homelab Main / validate (push) Waiting to run Details
Homelab Main / running-update (push) Blocked by required conditions Details
Homelab Main / debian-ops (push) Blocked by required conditions Details

This commit is contained in:
juvenal.diaz 2026-10-22 16:03:11 -06:00
parent ac11628ee4
commit baf8fcf70c
2 changed files with 20 additions and 2 deletions

View File

@ -121,6 +121,8 @@ def disk_self_heal_command(payload: dict[str, Any], names: set[str]) -> list[str
for labels in labels_list:
node = str(labels.get("node") or "")
if re.fullmatch(r"pimox-cp(?:-\d+)?", node):
return ["./jeannie", "workers", "disk-cleanup", "control-plane", "--yes"]
match = re.fullmatch(r"pimox-worker-(\d{1,2})", node)
if match:
return ["./jeannie", "workers", "disk-cleanup", str(int(match.group(1))), "--yes"]
@ -140,6 +142,8 @@ def disk_self_heal_command(payload: dict[str, Any], names: set[str]) -> list[str
if len(fields) < 4 or fields[1] != instance:
continue
node = fields[3]
if re.fullmatch(r"pimox-cp(?:-\d+)?", node):
return ["./jeannie", "workers", "disk-cleanup", "control-plane", "--yes"]
match = re.fullmatch(r"pimox-worker-(\d{1,2})", node)
if match:
return ["./jeannie", "workers", "disk-cleanup", str(int(match.group(1))), "--yes"]

View File

@ -28,8 +28,8 @@ Commands:
rebalance Restart evicted/pending pods and show scheduling pressure
disk-status [index|all] Read-only filesystem and container-runtime pressure report
disk-status control-plane Read-only control-plane VM filesystem/runtime report
disk-cleanup [index|all] [--yes]
Prune unused images and old pod logs on selected worker(s)
disk-cleanup [index|all|control-plane] [--yes]
Prune unused images and old pod logs on selected node(s)
EOF
}
@ -349,6 +349,20 @@ disk_cleanup() {
echo "Re-run with workers disk-cleanup ${target} --yes to prune unused images and pod logs older than 3 days."
return 0
fi
if [[ "${target}" == "control-plane" || "${target}" == "cp" ]]; then
IFS=$'\t' read -r host user key node < <(control_plane_entry)
echo "===== cleaning control plane (${node}, ${host}) ====="
ssh -i "${key}" -o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new "${user}@${host}" 'bash -s' <<'REMOTE'
set -u
echo "-- pruning unused container images"
sudo crictl rmi --prune 2>&1 || true
echo "-- deleting pod/container logs older than 3 days"
sudo find /var/log/pods /var/log/containers -xdev -type f -mtime +3 -print -delete 2>/dev/null || true
echo "-- filesystem after cleanup"
df -hP / /var/lib/containerd /var/lib/kubelet /var/log 2>/dev/null || true
REMOTE
return 0
fi
for index in $(target_indexes "${target}"); do
IFS=$'\t' read -r host user key node < <(worker_entry "${index}")
echo "===== cleaning worker ${index} (${node}, ${host}) ====="