fix(operator): scale kopia cache PVC reserve with PVC size#59
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖
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).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_sizealready prevents).Shape
KOPIA_CACHE_RESERVE_MB(fixed) →KOPIA_CACHE_RESERVE_MIN_MB+KOPIA_CACHE_RESERVE_FRACTION = 0.30.kopia_content_cache_mbcomputesmax(min_reserve, fraction × PVC)and subtracts that from PVC size.kopia_content_cache_mb_floor_for_small_pvc,kopia_content_cache_mb_scales_with_snapshot) updated to reflect the new formula.