diff --git a/docs/cluster-overview.md b/docs/cluster-overview.md index 622f017..3101317 100644 --- a/docs/cluster-overview.md +++ b/docs/cluster-overview.md @@ -391,6 +391,33 @@ Label discipline that must not be broken: Workflow labels actually present in the local checkouts *(live grep of `.forgejo/workflows`)*: `docker` (×8) and `docker-amd64` (×3) in `onionwire`; `deploy-arm64`, `docker-amd64` in `sirius-growth`; `docker-amd64` in `siriusdevops-contact`. +### 6.5 Nightly disk reclamation (`forgejo/forgejo-runner-prune`) + +`apps/base/forgejo/prune-cronjob.yaml`, `17 4 * * *` **UTC** (the repo's one CronJob timezone convention), `concurrencyPolicy: Forbid`, `startingDeadlineSeconds: 1800`, `backoffLimit: 1`, `activeDeadlineSeconds: 3600`. + +**Two containers, because there are two kinds of daemon.** `host-daemon` (`docker:27-cli`) mounts the Pi's `/var/run/docker.sock`; `dind-daemons` (`alpine/k8s:1.36.4`) discovers in-cluster dind daemons — pods with label `app=forgejo-runner` **that have a container named `dind`** — and runs the same prune logic inside each over the exec API. The ServiceAccount `forgejo-prune` has only `pods get,list` and `pods/exec create` in namespace `forgejo`. No pod names are in the manifest, so the two arm64 dind daemons from the arm64 migration are picked up the first night they exist (proved by creating an unrelated `app=forgejo-runner` dind pod: the job reported `found=2 pruned=2`). + +**Retention.** Exited containers > 48 h, unused **Pi-host** images > 168 h (a week of rollback for the sites). Build cache is capped at **20 GB** on the Pi host and **4 GB** per dind daemon; above the cap the script walks `--filter until=` down from 72 h to 0 s and stops as soon as the cache is under the cap, so the newest layers survive and a cold cache is the last resort. In-cluster images are **dangling-only** pruned: an `until` filter on a *pulled* image compares the upstream build date, so it would delete `node:20-bullseye` / `rust:*-bookworm` every night and make every job cold. + +**Named volumes are never pruned** (`docker volume prune` is forbidden): `onionwire-target-ci` (95.8 GB on the Pi), the Android SDK/Gradle/cargo-registry volumes and the cargo registries are shared CI state. Every run prints `docker system df -v` per daemon so growth is recorded before it becomes an outage. The Pi host currently holds **33 volumes / 169.7 GB, 48.67 GB reclaimable**; capping any of them is a separate decision. + +**Busy guard.** A daemon with a running container is skipped and the Job still exits 0: on the dind daemons *any* running container counts (they have none when idle), on the Pi host a running container younger than 180 min counts (the standing containers — `sirius-growth-site`, `handyman-site`, `garage`, `registry` — are days old, so no name whitelist is needed). A busy night is not a red job; a *missing* night is what alerts. + +Force a run (safe any time; it self-skips when busy): + +```bash +kubectl -n forgejo create job --from=cronjob/forgejo-runner-prune prune-manual-$(date +%s) +kubectl -n forgejo logs job/prune-manual- -c host-daemon # Pi daemon +kubectl -n forgejo logs job/prune-manual- -c dind-daemons # every dind daemon +``` + +**Two premises worth writing down, because the code depends on them** (both verified 2026-10-27): + +- The build-cache *capacity* flags are a no-op on this buildx (0.20.1). `--keep-storage`, `--max-storage` (rejected: unknown flag) and `--max-used-space` all report `Total: 0B` with a cache over the cap — a 21.44 GB cache with `--max-used-space 20GB`, and a 541 MB cache with `--max-used-space 100MB`. `--filter until=` *does* reclaim (541 MB → 0 with `until=0s`), which is why the cap is enforced by walking age windows. +- `kubelet_volume_stats_used_bytes` / `_capacity_bytes` **do not exist on this cluster**. kubelet v1.36.4 exposes `kubelet_volume_metric_collection_duration_seconds` but no volume stats for any node (`kubectl get --raw /api/v1/nodes//proxy/metrics | grep volume_stats` is empty, zero series in Prometheus). The per-PVC rules in `monitoring/controllers/home/prune-alerts.yaml` are therefore correct-but-inert; live coverage is the node-filesystem alert, because every local-path PV lives on siriussec's `/`. + +**Alerts** (`PrometheusRule monitoring/forgejo-prune`, label `release: kube-prometheus-stack`): `ForgejoPruneCronJobStale` (last success > 26 h, or the series absent), `ForgejoPruneJobFailed` (`kube_job_status_failed` for `forgejo-runner-prune-*` > 0 — `kube_job_failed` no longer exists), `NodeFilesystemFillingUp` / `NodeFilesystemCritical` (root fs > 85 % / > 92 % per node, joined to the hostname via `node_uname_info`), plus `RunnerDindPvcHighWatermark` / `RunnerDindPvcCritical` (85 % / 95 %, inert as above). Alertmanager is disabled in this stack, so they surface in Prometheus → Alerts and Grafana → Alerting, not as pages. + --- ## 7. CI/CD flow