Repository navigation
[NO-JIRA] bazel-reap: reclaim idle lgtm-mono container Bazel output bases (>6h idle) - #1075
Merged
Merged
Conversation
… ~/.local/state/lgtm/mono/bazel
The lgtm-mono docker container (the lgtm review service) runs Bazel with
--output_user_root=/home/dev/.local/state/lgtm/mono/bazel, bind-mounted at the
same path inside the container. It creates one output base (3-5 GB) per
food-truck/mono PR worktree (/home/dev/projects/mono/.worktrees/lgtm-pr-<N>).
The service frees a base only when its PR merges, so unmerged or closed PRs
leave bases behind forever, and bursts can fill the root disk.
Adds a container-root pass to bazel-reap:
- Root seam BAZEL_REAP_CONTAINER_BASE (default ~/.local/state/lgtm/mono/bazel);
missing root is a clean no-op.
- Policy: reap when idle >= 6h (seam BAZEL_REAP_CONTAINER_IDLE_MIN, default 360),
regardless of disk pressure.
- Candidates: direct children named exactly 32 lowercase hex chars; skips
cache/, install/, _reaping-*, and non-hex.
- Server liveness: server.pid.txt is ignored (pid is in container namespace).
Uses /proc probe (bazelReapInUsePy) on host to check cwd and open fds.
Probe failure ("error") keeps the base. Live-verified against lgtm-mono JVM.
- Idle age: newest mtime among <base>/command.log, <base>/server/, and
<base>/DO_NOT_BUILD_HERE. If none exists, keep.
- Deletion: rename-then-delete (_reaping-<name>.*), retries stale _reaping-*
dirs (including those left by lgtm-mono's merge reaper). Honours DRY_RUN.
- Shared per-pass budget MAX_PER_PASS.
- 9 new regression tests in users/dev/test-bazel-reaper.sh (66 -> 91 passing).
Updated anti-vacuity pin in flake.nix bazel-reaper-tests check.
Skip symlinks (chmod -R would follow one to its target); test the real live signal (an open fd in the base, not a cwd); say plainly the tier bounds accumulation and is not burst relief. Refs: lgtm-oqw2.77
johnnymo87
enabled auto-merge (squash)
December 2, 2026 20:40
…e lgtm-pr-* 30m window Measured the hour food-truck/mono moved into the container: 21 bases of 3.4 GB in 45 minutes, one per new PR head, box at 82%. The old service's lgtm-pr-* bases (which these replace one for one) were already reaped at 30 min idle under pressure; the container tier now matches that, and keeps 6 h otherwise. Refs: lgtm-oqw2.77
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.
Why
The lgtm-mono container runs bazel with its output root at
~/.local/state/lgtm/mono/bazel, on host disk. It creates one 3-5 GB output base per food-truck/mono PR worktree. The service frees a base only when its PR merges. Neither the nightly cleanup nor bazel-reap knows about this root, so the base of any unmerged PR stays forever. The root reached 36 GB within 30 minutes of mono moving to the container (lgtm-oqw2.77). Jonathan approved the policy: reap a base after more than 6 h idle, only when nothing is using it, by rename-then-delete.What
bazel-reap gets a "container" tier that runs after the existing tiers and shares their per-pass budget.
cache/,install/and symlinks are skipped.command.log,server/andDO_NOT_BUILD_HEREmust be at least 6 h old. A base with none of those files is kept./procprobe, notserver.pid.txt, because that pid is in the container's namespace. Verified live: the container's server JVMs holdserver/jvm.outopen at the same path, and the probe reportsin_use._reaping-*, then delete. Leftovers from an earlier pass, or from the service's own merge-time reaper, are finished off. Dry-run is honoured.lgtm-pr-*bases, which these replace one for one. In the 45 minutes after mono moved, 21 bases of 3.4 GB appeared while the box sat at 82%. This goes beyond the approved 6 h rule only to match what the old service's bases already got.The previous tier's early
exit 0on a missing~/.cache/bazelbase now skips to the container pass instead.Verification
test-bazel-reaper.shpasses 98/0, with 11 new container tests, including one where only an open fd holds the base.checks.bazel-reaper-testsbuilds.