Skip to content

feat(maintenance): prune anonymous volumes no container uses, weekly on prometheus - #1683

Merged
Gerrrt merged 5 commits into
mainfrom
feat/prune-dangling-volumes
Nov 23, 2026
Merged

Gerrrt merged 5 commits into
mainfrom
feat/prune-dangling-volumes

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

What changed

make prune-images, the weekly homelab-prune-images job on prometheus, now also runs docker volume prune after the image prune. Its before-and-after journal lines now report volumes as well as images. The unit's description and comment, schedule-maintenance.md's failure table, the critical-alert disk guidance and the changelog are updated to match. The agent hosts' scripts/prune-images.sh is unchanged.

Why

The 2026-11-13 audit of prometheus found 69 dangling anonymous volumes, left behind by validation and scratch runs. By 2026-11-23 there were 99, and nothing removed them. They were pruned by hand today; this keeps them from building up again.

Blast radius

The monitoring host's Docker volumes. docker volume prune --filter label=com.docker.volume.anonymous removes only anonymous volumes that no container references, running or stopped. So a named volume (every stack's data) is never removed, even while its stack is down. The filter is explicit because prune's own default depends on the request's API version, and a request below 1.42 would also take named volumes. It runs under the backups lock, as before.

  • No change to network segmentation or firewall rules
  • No new port published to a VLAN that could not already reach the service
  • No credential added outside secrets/*.sops.yaml

Verification

  • Probe on prometheus (Docker 29.9.1, API 1.56): a dangling anonymous volume was removed by docker volume prune -f, and a dangling named volume survived it.

  • After review: the API-version guard was replaced with the label filter. With DOCKER_API_VERSION=1.41, the filtered prune removed a dangling anonymous volume and kept a dangling named one.

  • make -n prune-images renders the recipe as intended.

  • python3 scripts/check_docs.py: docs OK.

  • ./scripts/lint.sh: every check passes. editorconfig first flagged space-indented continuation lines in the Makefile, now tabs.

  • make validate: exit 0, 373 PASS, 5 SKIP. The skips: the tmpfs path refusal (CI covers it), and four checks that need the deployment checkout (unit syntax, installed timers, the sensitive stack's timers, and the homelab-* units' paths). It started on the first commit, and the review fix and the merges of main landed in the worktree while it ran, so it is not a clean run of the final head. Lint, the docs check and systemd-analyze verify were re-run on the final head and pass, and CI runs the full set.

  • After merge, sudo make install-timers on prometheus is needed, because converge does not install units.

  • make validate passes (5 skipped, listed above)

  • Deployed to the lab and confirmed working

  • Docs updated (docs/, service README, or docs/roadmap.md)

🤖 Generated with Claude Code

…on prometheus

Validation and scratch runs leave anonymous volumes behind: 69 at the
2026-11-13 audit, 99 by 2026-11-23. make prune-images now runs
docker volume prune after the image prune. Without --all that removes
only com.docker.volume.anonymous volumes, so named volumes survive a
stack being down; on an API older than 1.42 the step refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 19:17
@Gerrrt
Gerrrt enabled auto-merge (squash) November 23, 2026 19:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The daemon-version guard can still allow API requests below 1.42 to prune named volumes, risking retained stack data unless pruning explicitly filters for anonymous volumes.

1 open issue
What changed in this PR

Extends the monitoring host’s weekly image cleanup to reclaim unused anonymous Docker volumes left by validation and scratch runs. Agent-host maintenance remains unchanged.

Changes:

  • Adds volume pruning, a server API-version guard, and before/after volume usage reporting.
  • Updates service metadata, operational guidance, and the changelog to describe the expanded cleanup.
File Description
systemd/​homelab-prune-images.service Updates the description and comments to include volume cleanup.
Makefile Adds guarded volume pruning and volume usage reporting.
docs/​runbooks/​triage-a-critical-alert.md Identifies abandoned anonymous volumes as a disk-usage cause.
docs/​runbooks/​schedule-maintenance.md Documents agent differences and volume-prune failure cases.
docs/​changelog.md Records the cleanup change and unit installation guidance.

Review effort: Balanced

Comment thread Makefile Resolved
Gerrrt and others added 4 commits November 23, 2026 19:21
…API check

The daemon's API version does not bound the request's: an old client or
DOCKER_API_VERSION=1.41 still sends a pre-1.42 prune, which takes named
volumes. Filter on com.docker.volume.anonymous instead; an API 1.41
request with the filter kept a dangling named volume on prometheus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gerrrt
Gerrrt merged commit ae231b7 into main Nov 23, 2026
10 checks passed
@Gerrrt
Gerrrt deleted the feat/prune-dangling-volumes branch November 23, 2026 19:50
Gerrrt added a commit that referenced this pull request Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants