mirror of
https://github.com/games-on-whales/LXC2Docker.git
synced 2026-10-15 12:52:04 +00:00
[PR #57] [MERGED] feat(daemon): disk-pressure guardrail to stop runaway writes filling the host #57
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
games-on-whales/LXC2Docker#57
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/games-on-whales/LXC2Docker/pull/57
Author: @JBailes
Created: 6/5/2026
Status: ✅ Merged
Merged: 6/5/2026
Merged by: @JBailes
Base:
main← Head:feat/disk-pressure-guardrail📝 Commits (1)
507b8ecfeat(daemon): disk-pressure guardrail to stop runaway writes filling the host📊 Changes
7 files changed (+302 additions, -3 deletions)
View changed files
📝
cmd/docker-lxc-daemon/main.go(+9 -1)📝
internal/api/events.go(+35 -0)📝
internal/api/router.go(+2 -2)➕
internal/lxc/diskspace.go(+167 -0)➕
internal/lxc/diskspace_test.go(+82 -0)📝
internal/lxc/manager.go(+6 -0)📝
readme.md(+1 -0)📄 Description
Why
A container bind-mounting a host directory — e.g. Wolf mounting a Steam game library into the Steam container — can fill the underlying filesystem with no warning. When that filesystem is the host root (as on a PVE node where
/etc/wolf/profile-datalives on a small root pool), a game download silently fills it and destabilizes the whole node. The daemon had zero visibility into this.What
A free-space guardrail,
--min-free-disk-gb(default 2,0disables):statfseach filesystem the daemon writes to (state dir, LXC path, ZFS pool mountpoint, and running containers' writable bind sources, deduped by device) and emit an edge-triggered warning when one crosses below the threshold: a log line + a daemon-scopeddisk_pressureevent on the Docker event stream (and adisk_pressure_recoveredevent when it clears).Note: this catches the runtime fill (downloads during gameplay), which a create-time check alone would miss.
Implementation
internal/lxc/diskspace.go—FreeBytes,watchedPaths,StartDiskPressureWatcher,checkCreateDiskPressure,humanBytes.internal/api/events.go—DiskPressureEmitter, wired throughNewHandlerWithHooks.cmd/.../main.go— flag +SetMinFreeBytes+ watcher start.Tests
Unit tests cover
FreeBytes(real fs + missing path), the create pre-flight (over-threshold reject, read-only skip, disabled, under-threshold allow), andhumanBytes.make test(unit + integration) green.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.