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
This commit is contained in:
2026-08-30 09:23:09 -07:00
parent 136bfaf0f2
commit 686c962ea9
2 changed files with 13 additions and 7 deletions
@@ -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
+1 -1
View File
@@ -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)