Skip to content

fix(crs): pull prebuilt images instead of rebuilding in prepare phase - #140

Merged
azchin merged 6 commits into
mainfrom
fix/prepare-pull-prebuilt-images
Mar 20, 2026
Merged

azchin merged 6 commits into
mainfrom
fix/prepare-pull-prebuilt-images

Conversation

@0xdkay

@0xdkay 0xdkay commented Mar 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Remove --set=*.cache-from / --set=*.cache-to overrides that broke per-target registry cache. The framework was setting cache-from to {registry}/{crs_name}:{version} for all targets, but actual images have distinct per-target names (e.g., multilang-given_fuzzer-clang, multilang-given_fuzzer-crs). The --set=* replaced the correct HCL-defined refs, causing silent cache misses on every target.
  • Add pull-first strategy to prepare(). Before running docker buildx bake, parse the HCL build plan via bake --print, docker pull all registry-tagged images, and tag them locally. Falls back to full bake build if any pull fails.

Context

oss-crs prepare was always building from scratch (~30+ min for given_fuzzer) even when prebuilt images existed in the registry. Two issues:

  1. --set=*.cache-from used the CRS name for all targets, overriding per-target refs in the HCL:
# HCL defines (correct):
multilang-given_fuzzer-clang → cache-from: ghcr.io/.../multilang-given_fuzzer-clang:1.0.0

# Framework overrides with (wrong):
multilang-given_fuzzer-clang → cache-from: ghcr.io/.../atlantis-multilang-given_fuzzer:1.0.0
  1. Even with correct cache-from, type=registry doesn't work with the docker buildx driver for multi-stage builds without inline cache metadata.

Verified with docker buildx bake --print that the override replaces (not appends) per-target values.

Test plan

  • Unit tests: 192 passed (8 prepare-specific tests)
  • oss-crs prepare pulls 6 images from registry instead of building
  • Works after docker system prune (the original reported failure case)
  • Verify oss-crs prepare --publish still builds and pushes correctly
  • Verify a CRS without published images falls back to bake gracefully

@0xdkay
0xdkay requested a review from azchin March 20, 2026 15:27
@0xdkay
0xdkay force-pushed the fix/prepare-pull-prebuilt-images branch from 51dbed7 to 5be3c2c Compare March 20, 2026 15:28

@azchin azchin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a --no-pull or --force-rebuild to oss-crs prepare so it can build the images locally without publishing?

@0xdkay
0xdkay force-pushed the fix/prepare-pull-prebuilt-images branch 2 times, most recently from fdba502 to 4b8fcc8 Compare March 20, 2026 16:00
0xdkay added 6 commits March 20, 2026 16:06
Signed-off-by: Dongkwan Kim <0xdkay@gmail.com>
Signed-off-by: Dongkwan Kim <0xdkay@gmail.com>
Signed-off-by: Dongkwan Kim <0xdkay@gmail.com>
type=bool caused --publish false to parse as True (bool("false") == True).
Now works as a simple flag: --publish to enable, omit to disable.

Signed-off-by: Dongkwan Kim <0xdkay@gmail.com>
Skip pulling prebuilt images and always build locally via bake.
Useful for local development when images need to be rebuilt.

Signed-off-by: Dongkwan Kim <0xdkay@gmail.com>
Signed-off-by: Dongkwan Kim <0xdkay@gmail.com>
@0xdkay
0xdkay force-pushed the fix/prepare-pull-prebuilt-images branch from 4b8fcc8 to c7c6a94 Compare March 20, 2026 16:08
@0xdkay

0xdkay commented Mar 20, 2026

Copy link
Copy Markdown
Collaborator Author

@azchin I've added --no-pull.

@azchin
azchin merged commit 520674e into main Mar 20, 2026
6 checks passed
@azchin
azchin deleted the fix/prepare-pull-prebuilt-images branch March 20, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants