[PR #44] [MERGED] feat(pve): reap orphaned image tarballs from pve-templates/ #45

Closed
opened 2026-10-15 12:51:35 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/games-on-whales/LXC2Docker/pull/44
Author: @JBailes
Created: 5/31/2026
Status: ✅ Merged
Merged: 5/31/2026
Merged by: @JBailes

Base: main ← Head: fix/reap-orphan-tarballs


📝 Commits (1)

  • 2fd3686 feat(pve): reap orphaned image tarballs; log tarball-removal errors

📊 Changes

3 files changed (+145 additions, -3 deletions)

View changed files

📝 internal/lxc/manager.go (+9 -2)
📝 internal/lxc/pve_tarball.go (+55 -0)
📝 internal/lxc/pve_tarball_test.go (+81 -1)

📄 Description

Closes the symmetric gap to the leaked-CT reaper (#43). docker rmi already deletes a tarball-backed image's .tar.gz and the OCI blobs are cleaned at pull time, so a normal pull→rmi cycle leaves nothing behind. But if an image record is ever lost (crash, or a scheme migration) RemoveImage never runs for it and the tarball lingers forever under pve-templates/.

Changes

  • reapOrphanTarballs() added to the GC cycle: deletes any pve-templates/*.tar.gz not referenced by an image record's TemplateTarball. Guarded exactly like reapOrphanCTs — pullOCI writes the tarball before AddImage, so the same grace window (orphanCTGrace) skips a pull in flight, plus a store re-check immediately before each delete.
  • RemoveImage no longer ignores the os.Remove error — logs it (other than not-exist) so a left-behind tarball is visible; the reaper is the backstop.

Tests

  • TestReapOrphanTarballs: referenced tarball survives, aged orphan reaped, in-grace (mid-pull) tarball survives.
  • TestReapOrphanTarballsSkippedWhenNotPVE: non-PVE mode never touches tarballs.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/games-on-whales/LXC2Docker/pull/44 **Author:** [@JBailes](https://github.com/JBailes) **Created:** 5/31/2026 **Status:** ✅ Merged **Merged:** 5/31/2026 **Merged by:** [@JBailes](https://github.com/JBailes) **Base:** `main` ← **Head:** `fix/reap-orphan-tarballs` --- ### 📝 Commits (1) - [`2fd3686`](https://github.com/games-on-whales/LXC2Docker/commit/2fd3686f6b9e0d11f3a3f7fb27050e7efd551d55) feat(pve): reap orphaned image tarballs; log tarball-removal errors ### 📊 Changes **3 files changed** (+145 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `internal/lxc/manager.go` (+9 -2) 📝 `internal/lxc/pve_tarball.go` (+55 -0) 📝 `internal/lxc/pve_tarball_test.go` (+81 -1) </details> ### 📄 Description Closes the symmetric gap to the leaked-CT reaper (#43). `docker rmi` already deletes a tarball-backed image's `.tar.gz` and the OCI blobs are cleaned at pull time, so a normal pull→rmi cycle leaves nothing behind. But if an image record is ever lost (crash, or a scheme migration) `RemoveImage` never runs for it and the tarball lingers forever under `pve-templates/`. ## Changes - `reapOrphanTarballs()` added to the GC cycle: deletes any `pve-templates/*.tar.gz` not referenced by an image record's `TemplateTarball`. Guarded exactly like `reapOrphanCTs` — `pullOCI` writes the tarball before `AddImage`, so the same grace window (`orphanCTGrace`) skips a pull in flight, plus a store re-check immediately before each delete. - `RemoveImage` no longer ignores the `os.Remove` error — logs it (other than not-exist) so a left-behind tarball is visible; the reaper is the backstop. ## Tests - `TestReapOrphanTarballs`: referenced tarball survives, aged orphan reaped, in-grace (mid-pull) tarball survives. - `TestReapOrphanTarballsSkippedWhenNotPVE`: non-PVE mode never touches tarballs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-15 12:51:35 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
games-on-whales/LXC2Docker#45
No description provided.