Skip to content

Clean up stale VM log files #5

Closed

Description

@JAORMX

Problem

After each session, brood-box leaves behind log files at ~/.config/broodbox/vms/<name>/broodbox.log. These are never automatically cleaned up. Over many sessions, they accumulate and consume disk space indefinitely.

While brood-box correctly cleans up VM data directories, SSH keys, and workspace snapshots, log files are the one gap.

Proposed Solution

Add automatic cleanup of stale VM log directories under ~/.config/broodbox/vms/. Options to consider:

  • Age-based cleanup: Remove log directories older than N days (e.g., 7 or 30) at CLI startup
  • Session-scoped cleanup: Remove the VM parent directory (not just the data/ subdirectory) after each session, unless a --keep-logs flag is passed
  • Manual cleanup: Add a task clean-logs target or a bbox cleanup subcommand

The cleanup logic should follow the same pattern as CleanupStaleSnapshots — run early in CLI invocation, check for liveness, and remove safely.

Current Behavior

  • internal/infra/vm/runner.go creates a per-VM directory at ~/.config/broodbox/vms/<name>/
  • propolis.WithCleanDataDir() removes the data/ subdirectory after the VM stops
  • The parent directory and broodbox.log persist indefinitely

Acceptance Criteria

  • Stale log directories are cleaned up automatically or via an explicit command
  • Active session logs are never deleted
  • Cleanup is safe for concurrent sessions

Activity

  1. added a commit that references this issue on Mar 3, 2026
    da5cb2a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions