refactor: replace download-source with mount-based API#133
Open
refactor: replace download-source with mount-based API#133
Conversation
60f840d to
cfe6318
Compare
Collaborator
Author
|
Hm note to self: double check whether these APIs are available to builder as well (or assess whether that's necessary) |
4056c1d to
59c377f
Compare
This was referenced Mar 23, 2026
- Create TestMountInfrastructure class in test_template_rendering.py - Add unit tests for fuzz_proj_path mount in build-target template - Add unit tests for target_source_path conditional mount in build-target template - Add unit tests verifying :ro flag on both mount types - Add unit test for fuzz_proj_path mount in run-crs-compose template - Create integration test stubs in test_mount_infrastructure.py (skipped) Signed-off-by: Andrew Chin <achin34@gatech.edu>
- Add fuzz_proj_path:/OSS_CRS_FUZZ_PROJ:ro mount to build-target template - Add conditional target_source_path:/OSS_CRS_TARGET_SOURCE:ro mount to build-target template - Add same volume mounts to run-crs-compose template per-CRS service section - Update render_build_target_docker_compose() to populate fuzz_proj_path and target_source_path context - Update render_run_crs_compose_docker_compose() to populate fuzz_proj_path and target_source_path context - Fix test_renderer_run_compose.py mock target to include proj_path and _has_repo attributes Signed-off-by: Andrew Chin <achin34@gatech.edu>
…o env_policy - Add OSS_CRS_FUZZ_PROJ=/OSS_CRS_FUZZ_PROJ to build_target_builder_env() system_env - Add OSS_CRS_FUZZ_PROJ=/OSS_CRS_FUZZ_PROJ to build_run_service_env() system_env - Add include_target_source parameter to build_target_builder_env() (default False) - Add include_target_source parameter to build_run_service_env() (default False) - Conditionally add OSS_CRS_TARGET_SOURCE=/OSS_CRS_TARGET_SOURCE when include_target_source=True - Pass include_target_source=target._has_repo from both renderer callers Signed-off-by: Andrew Chin <achin34@gatech.edu>
…rget extraction methods - Test WorkDir.get_target_source_dir() path structure and create flag behavior - Test Target.extract_workdir_to_host() docker create/cp/rm lifecycle - Test Target._resolve_effective_workdir_with_inspect_fallback() fallback logic Signed-off-by: Andrew Chin <achin34@gatech.edu>
…ction methods - WorkDir.get_target_source_dir() returns path <sanitizer>/builds/<build_id>/targets/<target_key>/target-source/ - Target._resolve_effective_workdir_with_inspect_fallback() prefers non-/src Dockerfile values, falls back to docker inspect for /src ambiguity - Target.extract_workdir_to_host() orchestrates docker create/cp/rm lifecycle with finally-block cleanup on failure Signed-off-by: Andrew Chin <achin34@gatech.edu>
… templates
- Remove include_target_source parameter from build_target_builder_env and build_run_service_env
- Add OSS_CRS_TARGET_SOURCE unconditionally to system_env in both functions
- Remove {%- if target_source_path %} guards from both compose templates
- Add test_build_target_env_always_includes_target_source and test_run_env_always_includes_target_source
- Rename test_target_source_mount_omitted_when_none to test_target_source_mount_always_present
- Add test_target_source_unconditional_in_run_crs and get_target_source_dir to _MockWorkDir
Signed-off-by: Andrew Chin <achin34@gatech.edu>
- Add resolved_source_path block in CRSCompose.build_target() after image build - Call target.extract_workdir_to_host() when target._has_repo is False - Pass target_source_path=resolved_source_path through crs.build_target lambda - Add target_source_path parameter to CRS.build_target() and __build_target_one() - Pass target_source_path to renderer.render_build_target_docker_compose - Add target_source_path parameter to render_build_target_docker_compose - Remove include_target_source from both renderer call sites - Use work_dir.get_target_source_dir for non-repo targets in run compose renderer - Add get_target_source_dir to work_dir mock in test_renderer_run_compose.py Signed-off-by: Andrew Chin <achin34@gatech.edu>
_DummyTarget and _DummyWorkDir in test_crs_compose_snapshot_sanitizer.py were missing attributes added in Phase 2, causing 6 test failures. Signed-off-by: Andrew Chin <achin34@gatech.edu>
…ount-based implementation - Replace TARGET/REPO enum values with FUZZ_PROJ/TARGET_SOURCE in base.py - Update abstract download_source signature to return None instead of Path - Add _FUZZ_PROJ_MOUNT and _TARGET_SOURCE_MOUNT module-level constants in local.py - Rewrite download_source as 10-line mount-path implementation - Delete all 5 old resolution helper methods (_resolve_repo_source_path, _normalize_repo_source_path, _translate_repo_hint_to_build_output, _resolve_downloaded_repo_path, _relative_repo_hint) - Remove unused os import from local.py - Update CLI help text for download-source parser (fuzz-proj, target-source) - Replace 16 old unit tests with 6 new mount-based tests (all passing) Signed-off-by: Andrew Chin <achin34@gatech.edu>
- Add OSS_CRS_FUZZ_PROJ and OSS_CRS_TARGET_SOURCE to env vars table - Rewrite download-source CLI section: fuzz-proj/target-source args with mount path details - Update implementation status table: Copies from /OSS_CRS_FUZZ_PROJ or /OSS_CRS_TARGET_SOURCE mounts - Remove old target/repo command references and OSS_CRS_PROJ_PATH/OSS_CRS_REPO_PATH in download-source context - Preserve builder sidecar /OSS_CRS_PROJ_PATH/test.sh reference (different context) Signed-off-by: Andrew Chin <achin34@gatech.edu>
…ew download-source API - Add download-source quick reference line with fuzz-proj/target-source types - Add OSS_CRS_FUZZ_PROJ and OSS_CRS_TARGET_SOURCE to env vars table - Add download-source to libCRS/README.md Build output command category - Preserve builder sidecar /OSS_CRS_PROJ_PATH/test.sh reference (different context) Signed-off-by: Andrew Chin <achin34@gatech.edu>
Signed-off-by: Andrew Chin <achin34@gatech.edu>
Signed-off-by: Andrew Chin <achin34@gatech.edu>
Signed-off-by: Andrew Chin <achin34@gatech.edu>
Signed-off-by: Andrew Chin <achin34@gatech.edu>
bc9baad to
cbaa019
Compare
Collaborator
|
I can review this from Friday. If anyone available, they can do that. |
…s context conflict) Signed-off-by: Dongkwan Kim <0xdkay@gmail.com>
…source Signed-off-by: Dongkwan Kim <0xdkay@gmail.com>
0xdkay
approved these changes
Apr 4, 2026
Collaborator
0xdkay
left a comment
There was a problem hiding this comment.
LGTM!
As we discussed previously, we will have the backward-compatibility: submit-build-output and download-build-output, to keep the directory structures from the Dockerfile if a user runs oss-fuzz projects.
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
Replaces the old
download-source target/repocommands with a new mount-based API (download-source fuzz-proj/target-source), eliminating the complex fallback resolution chain in libCRS.Three-phase refactor:
Mount Infrastructure — Add volume mounts for
/OSS_CRS_FUZZ_PROJ(read-only) and/OSS_CRS_TARGET_SOURCEto bothbuild-targetandrun-crs-composetemplates. Add corresponding env vars inenv_policy.py.WORKDIR Extraction — When
--target-source-pathis not provided, automatically extract source from the built Docker image's WORKDIR viadocker create/docker cp/docker rm. Make/OSS_CRS_TARGET_SOURCEunconditional — CRSes always find the mount present in both build and run phases.libCRS API Migration — Replace
SourceType.TARGET/REPOwithSourceType.FUZZ_PROJ/TARGET_SOURCE. Rewritedownload_source()as a simple 10-line mount-path copy (was ~170 lines of fallback resolution). Delete all old helper methods. Update docs.Key changes:
libCRS download-source fuzz-proj <dest>copies from/OSS_CRS_FUZZ_PROJlibCRS download-source target-source <dest>copies from/OSS_CRS_TARGET_SOURCEtarget/reposubcommands removed — argparse rejects them naturallydownload_source()return type changed fromPathtoNone(no nested repo resolution needed)local.pyUser Impact
Breaking change for CRS developers:
libCRS download-source target <dest>→libCRS download-source fuzz-proj <dest>libCRS download-source repo <dest>→libCRS download-source target-source <dest>download_source()Python API now returnsNoneinstead ofPathCRSes using the old
SourceType.TARGET/SourceType.REPOvalues need to update toSourceType.FUZZ_PROJ/SourceType.TARGET_SOURCE. Clean break — no deprecation period (CRSes are internal).Release Note / Changelog
CHANGELOG.md([Unreleased]) for user-facing changesValidation
uv run pytest oss_crs/tests/unit/test_libcrs_download_source.py— 6/6 pass (new mount-based tests)uv run pytest oss_crs/tests/unit/test_template_rendering.py— 6/6 pass (mount infrastructure)uv run pytest oss_crs/tests/unit/test_workdir_target_source.py— 4/4 pass (WorkDir path construction)uv run pytest oss_crs/tests/unit/test_target_workdir_extraction.py— 7/7 pass (WORKDIR extraction)uv run pytest oss_crs/tests/unit/test_env_policy.py— pass (unconditional env vars)uv run pytest oss_crs/tests/unit/test_crs_compose_snapshot_sanitizer.py— 6/6 pass (mock regression fixed)oss-crs build-target+oss-crs runwith crs-codex againstsanity-mock-c-delta-01— download-source commands work, agent receives correct source at/work/srcChecklist