Skip to content

fix(operator): scale kopia cache PVC reserve with PVC size#59

Merged
passcod merged 1 commit into
mainfrom
operator-kopia-cache-reserve
Jun 5, 2026
Merged

fix(operator): scale kopia cache PVC reserve with PVC size#59
passcod merged 1 commit into
mainfrom
operator-kopia-cache-reserve

Conversation

@passcod

@passcod passcod commented Jun 5, 2026

Copy link
Copy Markdown
Member

🤖

Summary

The fixed-2GiB reserve on the kopia cache PVC left too little headroom on smaller PVCs once you account for everything kopia actually puts on it besides the content cache: ext4's ~5% reserved blocks, the 0.5GiB metadata cache, the CLI and content logs, the live config, and the soft-cap overshoot that happens when kopia downloads new blobs faster than its LRU eviction.

Observed in the field: a 10GiB PVC sat at 88% steady-state full; a ~22GiB PVC went to 100%. At that point kopia can't even write its 4KB config file ("no space left on device"), and every restore Job pod fails inside 1–2 minutes.

Fix

Switch from a fixed reserve to a proportional one: max(2GiB, 30% × PVC).

PVC size Old content cap New content cap
10 GiB 8 GiB 7 GiB
22 GiB 20 GiB ~15 GiB
100 GiB 98 GiB 70 GiB

The 2 GiB floor still applies when the proportional value is smaller (it only kicks in below ~7 GiB PVCs, which the floor on kopia_cache_pvc_size already prevents).

Shape

  • KOPIA_CACHE_RESERVE_MB (fixed) → KOPIA_CACHE_RESERVE_MIN_MB + KOPIA_CACHE_RESERVE_FRACTION = 0.30.
  • kopia_content_cache_mb computes max(min_reserve, fraction × PVC) and subtracts that from PVC size.
  • Existing unit tests (kopia_content_cache_mb_floor_for_small_pvc, kopia_content_cache_mb_scales_with_snapshot) updated to reflect the new formula.

The previous fixed 2GiB reserve left too little headroom on small cache
PVCs once you account for everything the PVC actually has to hold besides
kopia's content cache: ext4 reserved blocks (~5% of capacity), the
metadata cache (0.5GiB), the CLI and content logs, the live config, and
the soft-cap overshoot that happens when kopia downloads new blobs faster
than its LRU eviction can keep up. On a 10GiB PVC the previous formula
gave an 8GiB content cap, and observed steady-state usage hit 88-100%
across replicas; once the filesystem is at zero free bytes kopia exits
immediately on "no space left on device" trying to write its config,
and every restore Job pod fails in 1-2 minutes.

Switch to a proportional reserve: max(2GiB, 30% × PVC). For a 10GiB PVC
the content cap drops from 8GiB to 7GiB; for a 22GiB PVC from ~20GiB to
~15GiB — both keep ~3-7GiB of true headroom for everything else.
@passcod passcod enabled auto-merge June 5, 2026 10:55
@passcod passcod merged commit e868f76 into main Jun 5, 2026
18 checks passed
@passcod passcod deleted the operator-kopia-cache-reserve branch June 5, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant