Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions infra/cargo-target-janitor/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Cargo target janitor

Keep fleet-worktree Cargo targets below the **150 GiB** cap. The primary
`~/git/code/pkgs/id/target` is out of scope. Only explicit directories under
`~/git/fleet/*/pkgs/id/target` and numeric `~/git/fleet/target-<task-id>`
ad-hoc targets are considered.
`~/git/code/pkgs/id/target` is out of scope. Considered: directories under
`~/git/fleet/*/pkgs/id/target`, the `~/git/fleet/queue/*` sub-worktrees'
`pkgs/id/target` (one level deeper — ~82 GiB the top-level-only scan never
saw, #6812), repo-root cargo targets `~/git/fleet/*/target` and
`~/git/fleet/queue/*/target` when they hold build products (a `debug`,
`release`, or `.fingerprint` dir — ~114 GiB, #6812; a checkout's root
target belongs to the checkout, a non-checkout probe/scratch dir's root
target is treated like an ad-hoc target except that its owning dir
still exists, so it ages out instead of reading as worktree-gone), and
numeric `~/git/fleet/target-<task-id>` ad-hoc targets.

## Safety policy

Expand All @@ -16,9 +23,17 @@ ad-hoc targets are considered.
task, a worktree whose branch has an open PR, an unmapped worktree/ad-hoc
target, or a worktree/target containing a current-user Cargo, rustc,
rust-analyzer, or build-script process cwd.
- Queue data is read through `~/hatch/tools/repo-queue.py`'s transient
Bitwarden credential path; credentials are never printed or persisted.
Open PRs are read with `gh`. If either source is unavailable, cleanup stops.
- Queue liveness comes from a claims source, picked per run and named in
the plan output/record (`claims_source`): the repo-queue helper's
transient Bitwarden credential path when that helper file still exists
(broker task ids + states), otherwise the GitHub fallback source —
`fleet queue fallback scan` live/contested claim markers unioned with
open issues carrying `queue/claimed`, keyed by issue number because
fallback claims live on issues (#6619). The fallback source has no
broker task states, so it never makes a target eligible via the
terminal-task reason; it only ever adds protection. Open PRs are read
with `gh`. If no claims source can be read, cleanup stops — and the
refusal now leaves a run record like every other run (#6812).
Both liveness reads are paginated to completion (#6618) — claimed
tasks by offset, open PRs by page — and a read that cannot complete
within its page bound also stops cleanup: a truncated protection
Expand All @@ -38,7 +53,11 @@ ad-hoc targets are considered.
wildcard or force-delete command is used. At most 20 targets are planned
per invocation; the hourly timer continues later if still over cap.
- Logs and run summaries live under
`~/.local/state/cargo-target-janitor/runs/`.
`~/.local/state/cargo-target-janitor/runs/`. Every run writes a record
there, including refusals (`"event": "refused"` with the reason): a
janitor that cannot run must be visible in its own state, not only in
the systemd journal (#6812 — the helper-path failure ran hourly,
unrecorded, while the disk filled).
- If protected/open-PR or younger targets alone exceed the cap, the report and
systemd journal say `over_cap`; they are deliberately kept rather than
violating the safety exclusions. A maximum of 20 exact target paths is
Expand Down
Loading
Loading