Repository navigation
feat(runtime): add shutdown() method to gracefully stop all boxes - #155
Merged
Merged
Conversation
Implement runtime.shutdown() across all SDKs (Python, Node.js, C) to gracefully stop all running boxes with configurable timeout. Core changes: - Add boxes_stopped counter to RuntimeMetricsStorage - Implement num_running_boxes() calculation (created - stopped - failed) - Make box.stop() idempotent (early exit if already stopped) - Add unit tests for metrics calculation SDK bindings: - Python: async shutdown() + sync API wrapper - Node.js: async shutdown() via napi-rs - C: boxlite_runtime_shutdown() FFI function Examples and tests: - Add shutdown examples for Python, Node.js, and C - Add integration tests for Python and Node.js SDKs
The shutdown test requires the native binary and VM environment, which aren't available in CI unit tests. The Python test uses pytest.mark.integration to skip in CI; Node.js doesn't have an equivalent mechanism, so removing the test file. Integration tests should be run locally during development.
- Remove unused imports (os, Path, Iterator, Generator, boxlite) - Add TYPE_CHECKING imports for forward references (Boxlite, SyncBox, SyncExecution) - Add noqa: F401 for re-exported symbols via __all__.extend() - Fix E712: use `is True/False` instead of `== True/False` - Remove unused variable `expected_attrs`
DorianZheng
pushed a commit
that referenced
this pull request
Jun 26, 2026
Fix SDK network/secrets integration failures by avoiding the current VMM seccomp/gvproxy conflict and making MITM TLS validation work inside the jail. Test plan: - Remote e2e runner: Python #155 non-detach failure subset, 25 passed in 116.10s - Remote e2e runner: Node tests/network-secrets.integration.test.ts, 5 passed - A/B check without SDK Cargo gvproxy feature changes: Python subset 25 passed, Node network-secrets 5 passed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved secure upstream TLS validation by extending sandbox trust to include existing system CA bundles and cert files (read-only). * Prevented syscall filtering from disrupting network-enabled runs by skipping the VMM syscall filter when networking is active. * Updated network interception integration coverage to use a new upstream endpoint, keeping secret-substitution checks stable. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.
Summary
Implement
runtime.shutdown()across all SDKs to gracefully stop all running boxes with configurable timeout.boxes_stoppedcounter to track stopped boxesnum_running_boxes()calculation:created - stopped - failedbox.stop()idempotent (safe to call multiple times)shutdown()method to Python, Node.js, and C SDKsAPI
Files Changed
box_impl.rs,runtime_metrics.rsboxlite.h,ffi.rsruntime.rsruntime.rs,_boxlite.pyshutdown.c,shutdown.js,shutdown_example.pyshutdown.test.ts,test_shutdown.pyTest plan
cargo test -p boxlite --libpytest sdks/python/tests/test_shutdown.py -vcd sdks/node && npm test