From 686c962ea9a498500b13bd535daea706a015e57c Mon Sep 17 00:00:00 2001 From: rock Date: Sun, 30 Aug 2026 09:23:09 -0700 Subject: [PATCH] fix(ci): aggressive GC for heavy Rust cargo builds - GC CronJob runs 2x daily (02:00 & 05:00 UTC) instead of once (03:00) - Delete incomplete actcache uploads immediately (tmp/ dirs from failed writes) - Reduce actcache retention from 3 days to 1 day - Prevents cargo cache backlog on rust runner under heavy commit load - Incomplete entries were accumulating 900MB+ each, filling 1Gi PVC instantly --- .../forgejo-runner/templates/gc-cronjob.yaml | 18 ++++++++++++------ k8s/infra/forgejo-runner/values.yaml | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/k8s/infra/forgejo-runner/templates/gc-cronjob.yaml b/k8s/infra/forgejo-runner/templates/gc-cronjob.yaml index 79fb29d..bed8ce8 100644 --- a/k8s/infra/forgejo-runner/templates/gc-cronjob.yaml +++ b/k8s/infra/forgejo-runner/templates/gc-cronjob.yaml @@ -43,7 +43,7 @@ metadata: labels: app: forgejo-runner-gc spec: - schedule: {{ .Values.gc.schedule | quote }} + schedule: "0 2,5 * * *" # Run at 02:00 and 05:00 UTC (more frequent for heavy build workloads) concurrencyPolicy: Forbid successfulJobsHistoryLimit: 3 failedJobsHistoryLimit: 3 @@ -126,12 +126,18 @@ spec: echo "[docker] after:" kubectl -n {{ .Release.Namespace }} exec "$POD" -c dind -- docker system df 2>/dev/null || true - # 2. Actcache cleanup (runner container) — remove cached artifacts older than pruneAge - echo "[actcache] cleaning stale cache entries..." + # 2. Actcache cleanup (runner container) + echo "[actcache] cleaning incomplete and stale cache entries..." kubectl -n {{ .Release.Namespace }} exec "$POD" -c runner -- \ - sh -c 'find /data/.cache/actcache/cache -type f -mtime +{{ .Values.gc.actcacheMaxAgeDays }} -delete 2>/dev/null; \ - find /data/.cache/actcache/cache -type d -empty -delete 2>/dev/null; \ - echo "actcache size: $(du -sh /data/.cache/actcache/cache 2>/dev/null | cut -f1)"' || true + sh -c ' + # Delete incomplete/partial cache uploads immediately (tmp dirs) + find /data/.cache/actcache/cache -name "tmp" -type d -exec rm -rf {} + 2>/dev/null || true + # Delete cache entries not accessed in last {{ .Values.gc.actcacheMaxAgeDays }} day(s) + find /data/.cache/actcache/cache -type f -mtime +{{ .Values.gc.actcacheMaxAgeDays }} -delete 2>/dev/null || true + # Clean up empty directories + find /data/.cache/actcache/cache -type d -empty -delete 2>/dev/null || true + echo "actcache size: $(du -sh /data/.cache/actcache/cache 2>/dev/null | cut -f1)" + ' || true echo "" done diff --git a/k8s/infra/forgejo-runner/values.yaml b/k8s/infra/forgejo-runner/values.yaml index c7cd5f5..4ef52d0 100644 --- a/k8s/infra/forgejo-runner/values.yaml +++ b/k8s/infra/forgejo-runner/values.yaml @@ -63,4 +63,4 @@ gc: image: alpine/k8s:1.31.0 pruneAge: "72h" # Docker artifacts unused longer than this get pruned pruneAgeHours: 72 # Same as pruneAge but numeric for date arithmetic in shell - actcacheMaxAgeDays: 3 # actcache files older than N days get deleted + actcacheMaxAgeDays: 1 # actcache files older than N days (aggressive for heavy Rust cargo builds)