banger/internal/imagepull
Thales Maciel bddfa75feb
imagepull.Pull: don't eager-open layer readers
The eager "fetch once to surface network errors" loop in Pull was
opening each layer's Compressed() stream and immediately closing it
without draining. The go-containerregistry filesystem cache populates
lazily via tee-on-read — opening and closing without reading wrote
ZERO-BYTE blobs into the cache. Every subsequent pull of the same
digest then served those corrupted blobs, producing a 1 GiB ext4
containing nothing but banger's injected files.

Symptom caught during B-4 live verification: real debian:bookworm
pulls had 43 used inodes (out of 65536) and /usr contained only
/usr/local — the debian content was silently missing.

Fix: remove the eager-fetch loop entirely. Flatten naturally drains
layers when it reads them, and the cache populates correctly on that
path. Network errors now surface from Flatten instead of Pull, which
is fine — they surface at the same place they always had to.

Test TestPullCachesLayersAndReturnsImage → TestPullResolvesImageAnd
FlattenPopulatesCache, reworded to assert the new contract: Pull
resolves the image; Flatten is what populates the cache with
non-empty blobs.

Users with a corrupted cache from a pre-fix pull must clear it:
  rm -rf ~/.cache/banger/oci

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 19:03:52 -03:00
..
assets Phase B-3: first-boot sshd install 2026-04-16 18:20:33 -03:00
ext4.go Phase 1: imagepull package — pull, flatten, ext4 2026-04-16 17:22:13 -03:00
firstboot.go Phase B-3: first-boot sshd install 2026-04-16 18:20:33 -03:00
firstboot_test.go Phase B-3: first-boot sshd install 2026-04-16 18:20:33 -03:00
flatten.go Phase B-1: ownership fixup via debugfs pass 2026-04-16 18:04:22 -03:00
imagepull.go imagepull.Pull: don't eager-open layer readers 2026-04-16 19:03:52 -03:00
imagepull_test.go imagepull.Pull: don't eager-open layer readers 2026-04-16 19:03:52 -03:00
inject.go Phase B-3: first-boot sshd install 2026-04-16 18:20:33 -03:00
inject_test.go Phase B-3: first-boot sshd install 2026-04-16 18:20:33 -03:00
ownership.go Phase B-1: ownership fixup via debugfs pass 2026-04-16 18:04:22 -03:00