Skip to content

HAM-113: bound /var/log so log spam can't fill the SD card#73

Open
pbitzer wants to merge 1 commit into
0.4.xfrom
feature/ham-113-log-size-cap
Open

HAM-113: bound /var/log so log spam can't fill the SD card#73
pbitzer wants to merge 1 commit into
0.4.xfrom
feature/ham-113-log-size-cap

Conversation

@pbitzer

@pbitzer pbitzer commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Caps /var/log growth so a runaway log source can't fill the SD card — the disk-fill that hit mj42 (2026-04), mj54 (2026-05), and mj05 (2026-07).

Three defenses, independent of the spam source:

  • journald SystemMaxUse=500M drop-in (files/journald-sensor-bounds.conf)
  • rsyslog maxsize 100M injected into each /etc/logrotate.d/rsyslog stanza (idempotent; backs up the original to /var/backups/)
  • hourly logrotate run (files/logrotate-hourly.sh/etc/cron.hourly/mjolnir-logrotate) so maxsize is enforced within the hour, not once a day

Delivered as both a unified_install step (configure_log_bounds in hardware.sh, Phase 4) and an idempotent fleet-remediation script (scripts/apply_log_bounds.sh, with --check) for already-deployed units.

Why

Defense-in-depth for HAM-112 (brokkr science_ingest retries with no backoff). Even after HAM-112 is fixed, this catches any future runaway log source. HAM-112 itself is deferred (modifying brokkr's untested core on the deployed fleet is too risky right now); this PR makes the disk-fill non-fatal in the meantime.

Testing

  • 11 new unit tests (tests/unified/test_log_bounds.py), incl. a real install.sh --dry-run through Phase 4 asserting the manifest ops.
  • shellcheck-clean additions.
  • E2E validated on mj05: applied via the remediation script, logrotate -d parses clean, /var/log bounded (journal 1.2G→536M), idempotent re-run, --check reports all present. mj05 is now remediated.
  • The E2E caught a real bug — the rsyslog backup was written into /etc/logrotate.d/, causing logrotate "duplicate log entry" errors; fixed to /var/backups/ with a regression test.

Note

The repo's tests/shell/test_shellcheck.py is already red on 0.4.x under shellcheck 0.11.0 (pre-existing SC2155/SC2046 in several libs). This PR adds zero new shellcheck warnings.

🤖 Generated with Claude Code

When the AGS is down, brokkr's science_ingest floods /var/log with no
backoff (HAM-112), filling the SD card (mj42, mj54, now mj05). Bound the
damage independent of the source: journald SystemMaxUse cap, maxsize on
the rsyslog logrotate stanzas, and an hourly logrotate run so the cap is
enforced within the hour. Ships as a unified_install step plus an
idempotent fleet-remediation script (scripts/apply_log_bounds.sh) for
already-deployed units. E2E-validated on mj05.

Co-Authored-By: Claude Opus 4.8 (1M context) <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.

1 participant