mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #265] [CLOSED] fix(sandbox): clean up empty serial logs and expire inactive logs #301
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#301
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/265
Author: @yingdi-shan
Created: 9/8/2026
Status: ❌ Closed
Base:
main← Head:fix/firecracker-log-retention📝 Commits (1)
6b14029fix(sandbox): clean up empty serial logs and expire inactive logs📊 Changes
17 files changed (+761 additions, -24 deletions)
View changed files
📝
config/default.toml(+4 -0)📝
docs/src/configuration/env-vars.md(+1 -0)📝
docs/src/configuration/reference.md(+23 -0)📝
docs/src/internals/networking.md(+1 -1)📝
docs/src/internals/persistence-artifact-inventory.md(+2 -2)📝
docs/src/internals/sandbox-testing.md(+5 -2)📝
src/bin/server.rs(+11 -1)📝
src/cfg.rs(+7 -0)📝
src/orchestrator/service.rs(+0 -7)📝
src/sandbox/firecracker/instance.rs(+10 -5)📝
src/sandbox/firecracker/mod.rs(+2 -0)📝
src/sandbox/firecracker/sandbox.rs(+154 -1)➕
src/sandbox/firecracker/serial_logs.rs(+513 -0)📝
src/sandbox/mod.rs(+4 -3)📝
src/sandbox/network/mod.rs(+9 -0)📝
tests/integration/orchestrator.rs(+14 -0)📝
tests/orchestrator_integration.rs(+1 -2)📄 Description
What
Remove empty managed Firecracker logs after confirmed process exit and expire inactive nonempty logs after a configurable retention period. Keep the existing
{serial_dir}/{sandbox_id}/layout.Why
Silent snapshot launches leave permanent directories and empty log files behind, growing the serial root with every sandbox created. Cleaning stopped sandboxes prevents this accumulation during normal operation.
Related issue
Closes #260. Alternative to #261.
Scope and non-goals
Includes cleanup after stop, retention, live-writer protection, documentation, and regression tests. No sharding, lazy capture, active-log rotation, or throughput improvement claim. Legacy directories and logs left after an abnormal drop or server crash require offline cleanup.
Design and behavior changes
.inactivemarker under the lock and remove empty known logs. Resuming an ID clears the marker before opening logs. Abnormal drop leaves logs unmarked, preserving late internal-logger output even with custom stdout/stderr paths.firecracker.serial_log_retention_secs, default 604800 (seven days). Zero disables expiry. Retention uses the newest directory/log modification time, refreshed after confirmed exit.Compatibility and operations
firecracker.serial_log_retention_secsandAENV_FIRECRACKER_SERIAL_LOG_RETENTION_SECS, default seven days..inactivemarker after stop.Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetCommands and results:
All builds and Rust tests run as the non-root workspace user. Test state and dependencies are isolated under
/tmp/aenv-serial-retention-tests; privileged tests use the repository capability runner.Skipped checks and reasons:
Risks and reviewer notes
The main review area is
src/sandbox/firecracker/serial_logs.rs: eligibility after confirmed exit, directory locking, and retention. Regression coverage includes late unlocked logger writes after abnormal drop, interrupted resume, cancellable lock contention, collection during repeated launches/stops, symlinks/custom entries, startup failure, retained history, and warm-log relocation.Unmarked logs need offline cleanup. Retention bounds eligible inactive-log lifetime; it does not limit active-log size, peak directory count, or compact an already expanded filesystem directory inode. Filesystem syscalls themselves cannot be interrupted by worker cancellation.
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.