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)