feat: unpack app tarballs from shadow volumes#49
Merged
Conversation
Add unit and integration tests for unpack_volume module: Unit Tests (tests/unit/test_unpack_volume.py): - Path traversal prevention (malicious tar members) - Thread safety with concurrent extraction attempts - Environment detection (RUNPOD_POD_ID, RUNPOD_ENDPOINT_ID) - Idempotency (multiple maybe_unpack calls) - Error handling (missing artifacts, corrupted tarballs) - Configuration (custom artifact paths, disable flags) Integration Tests (tests/integration/test_unpack_volume_integration.py): - End-to-end extraction with real tarballs - Multi-file directory structures - Large tarball extraction (50+ files) Coverage: 98% for unpack_volume.py module All 28 tests pass
Improvements to src/unpack_volume.py: - Add thread-safe extraction with threading.Lock and double-checked locking - Replace string-based path validation with Path.is_relative_to() - Improve exception handling (catch specific exceptions) - Add success logging after extraction - Make environment variable checking case-insensitive - Fix docstring to match actual behavior (raises, not returns False) Move constants to src/constants.py: - DEFAULT_APP_DIR = "/app" - DEFAULT_ARTIFACT_PATH = "/root/.runpod/archive.tar.gz" - Document FLASH_BUILD_ARTIFACT_PATH environment variable - Document FLASH_DISABLE_UNPACK environment variable These changes improve security, thread safety, and maintainability while maintaining backward compatibility.
Add comprehensive documentation for the volume unpacking mechanism in docs/Volume_Unpacking_System.md. Documents: - Runtime extraction flow with sequence diagrams - Security features (path traversal prevention) - Thread safety implementation (double-checked locking) - Environment detection and configuration - Error handling and exception hierarchy - Usage examples and debugging techniques - Performance characteristics - Testing coverage (98% coverage, 28 tests) This documentation explains how pre-packaged artifacts are automatically extracted from shadow volumes into the runtime environment for immediate code execution.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements automatic unpacking of application build artifacts from shadow volumes into the /app directory at runtime. The system extracts tarballs from a mounted project volume when deployed endpoints start, making code and dependencies immediately available.
Changes:
- Adds secure tarball extraction with path traversal prevention
- Implements thread-safe, idempotent unpacking with environment detection
- Integrates
sys.pathmanipulation to make extracted modules importable
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/unpack_volume.py | Core unpacking logic with security validation and thread-safe extraction |
| src/constants.py | Default paths and configuration constants for volume unpacking |
| tests/unit/test_unpack_volume.py | Comprehensive unit tests for extraction, security, and edge cases |
| tests/integration/test_unpack_volume_integration.py | End-to-end integration tests with real tarball scenarios |
| docs/Volume_Unpacking_System.md | Complete documentation of system design, usage, and performance characteristics |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
deanq
approved these changes
Jan 14, 2026
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.
deployed endpoints are expected to start with an empty
/appand a build artifact (theflash buildtarball, typicallyarchive.tar.gz) staged on a mounted project volume.at runtime startup, flash will:
FLASH_BUILD_ARTIFACT_PATHif set, otherwise it uses the canonical flash project path:/root/.runpod/archive.tar.gz./app: it safely extracts the tarball into/app./appimportable: it prepends/apptosys.pathso the extracted local modules + deps can be imported.Will still need to be wired up when executing locally within the worker.