Rust implementation of OCI Distribution Spec with granular access control

Add scheduled automatic garbage collection #8

Open pierrelf.com
Open opened by pierrelf.com

Problem #

Garbage collection only runs when manually triggered via POST /admin/gc. There is no way to schedule periodic automatic GC, meaning unreferenced blobs accumulate until an admin remembers to trigger cleanup.

Proposed Solution #

  • Add a --gc-interval CLI argument (e.g., --gc-interval 24h)
  • Spawn a background tokio task that runs GC on the configured interval
  • Use the existing gc::run_gc() function with configurable dry-run and grace period
  • Log GC results and expose last-GC metrics (timestamp, blobs freed, bytes freed)
  • Add grain_gc_last_run_timestamp and grain_gc_bytes_freed_total Prometheus gauges/counters
  • Keep the manual POST /admin/gc endpoint for on-demand runs

Files to modify #

  • src/main.rs - Spawn background GC task
  • src/args.rs - Add --gc-interval and --gc-grace-period args
  • src/metrics.rs - Add GC metrics
Sign up or Sign in to add to the discussion.