Skip to content

Fix unbounded service logs and HTTP/MQTT traces - #168

Open
Lash-L wants to merge 2 commits into
mainfrom
fix/bounded-log-retention
Open

Lash-L wants to merge 2 commits into
mainfrom
fix/bounded-log-retention

Conversation

@Lash-L

@Lash-L Lash-L commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Service logs and protocol traces currently append indefinitely, allowing long-running installations to accumulate gigabytes of data. This change rotates all six service logs and both JSONL traces, defaulting to 10 MiB per file with three numbered backups.

Closes #167.

Changes

  • Add validated retention settings to TOML and both Home Assistant add-on manifests. A backup count of zero still rotates the active file.
  • Serialize JSONL writes across threads and backend import paths, count UTF-8 bytes, and preserve complete records during rotation. A single oversized record can exceed the threshold; normal aggregate retention at the defaults is approximately 320 MiB.
  • Recover missing MQTT credentials and seed zone state from active logs and numbered backups before startup cleanup. Trim existing oversized files to recent complete lines with atomic replacement and remove excess backups when retention is reduced.
  • Read scene fallback history across rotations in chronological order so the latest coordinates win, and document configuration and upgrade behavior.

Validation

  • Full suite on Python 3.13: 431 passed.
  • Focused retention, logging, configuration, add-on, and credential tests on Python 3.11: 73 passed.
  • Coverage includes concurrent writes, zero backups, UTF-8 sizes, oversized records, failed atomic replacement, bounded-memory trimming, and state recovery before cleanup.
  • uv run mkdocs build --strict, uv build, and git diff --check passed. Confirmed the wheel includes the new retention module.
  • Docker image validation was not run locally because the Docker Desktop engine was unavailable.

This branch has not been deployed

No deployments
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.

Logs taking up gigabytes

1 participant