fix(server): prevent unbounded bus entry growth for sandbox IDs#138
Merged
johntmyers merged 1 commit intomainfrom Mar 5, 2026
Merged
Conversation
Closes #27 Add remove() methods to TracingLogBus, PlatformEventBus, and SandboxWatchBus to clean up entries when sandboxes are deleted. Wire cleanup into both handle_deleted (K8s reconciler) and delete_sandbox (gRPC handler). Reorder watch_sandbox to validate sandbox existence before subscribing to buses, preventing entries for non-existent IDs. Add one-time sandbox validation at stream open in push_sandbox_logs.
drew
pushed a commit
that referenced
this pull request
Mar 16, 2026
Closes #27 Add remove() methods to TracingLogBus, PlatformEventBus, and SandboxWatchBus to clean up entries when sandboxes are deleted. Wire cleanup into both handle_deleted (K8s reconciler) and delete_sandbox (gRPC handler). Reorder watch_sandbox to validate sandbox existence before subscribing to buses, preventing entries for non-existent IDs. Add one-time sandbox validation at stream open in push_sandbox_logs. Co-authored-by: John Myers <johntmyers@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #27
Summary
Prevents unbounded memory growth caused by sandbox bus entries (TracingLogBus, PlatformEventBus, SandboxWatchBus) that were never cleaned up when sandboxes were deleted. Additionally, WatchSandbox now validates sandbox existence before subscribing to buses (preventing entries for non-existent IDs), and PushSandboxLogs validates sandbox existence once at stream open.
Changes Made
crates/navigator-server/src/tracing_bus.rs: Addedremove()method toTracingLogBus(cleans upper_idandtailsmaps) andremove()method toPlatformEventBus. Added 7 unit tests.crates/navigator-server/src/sandbox_watch.rs: Addedremove()method toSandboxWatchBus. Added 3 unit tests.crates/navigator-server/src/sandbox/mod.rs: Wired bus cleanup intohandle_deletedreconciler — callsremove()on all three buses after sandbox deletion. Updatedspawn_sandbox_watcherto acceptTracingLogBusparameter.crates/navigator-server/src/grpc.rs: Wired bus cleanup intodelete_sandboxgRPC handler. Reorderedwatch_sandboxto validate sandbox existence before subscribing to buses (validate → subscribe → re-read snapshot). Added one-time sandbox validation at stream open inpush_sandbox_logs.crates/navigator-server/src/lib.rs: Passtracing_log_bustospawn_sandbox_watcher.architecture/gateway.md: Documented bus cleanup and validation behavior.Deviations from Plan
None — implemented as planned.
Tests Added
tracing_bus.rs(7 tests: remove cleans up maps, subscribe after remove creates fresh channel, remove closes active receivers, remove nonexistent is noop — for both TracingLogBus and PlatformEventBus) andsandbox_watch.rs(3 tests: remove cleans up, subscribe after remove creates fresh channel, remove nonexistent is noop)Documentation Updated
architecture/gateway.md: Added cleanup and validation notes to the bus sectionVerification
tmp/network_checks.py)