fix: add image-manifest=true to BuildKit cache export for ephemeral VMs #83
+208
−4
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
Fixes two related issues with BuildKit cache handling:
image-manifest=true, BuildKit's registry cache stores layer references pointing to external registries rather than copying actual layer blobsapplication/vnd.buildkit.cacheconfig.v0) that can't be unpacked by standard OCI toolsChanges
Fix 1: Enable proper cache blob storage
lib/builds/builder_agent/main.go- Addedimage-manifest=true,oci-mediatypes=trueto cache export optionslib/builds/cache.go- UpdatedExportCacheArg()helper for consistencylib/builds/cache_test.go- Updated test expectationFix 2: Skip conversion for cache images
lib/registry/registry.go- SkiptriggerConversion()forcache/*repos since they're not runnable containersTest coverage
lib/images/oci_test.go- Unit tests documenting the BuildKit cache mediatype limitationRoot causes
Issue 1: Without
image-manifest=true, BuildKit stores layer references like:Instead of copying the actual blob. Ephemeral BuildKit instances can't resolve these references.
Issue 2: When cache images are pushed, the registry triggers conversion to ext4 format. This calls
umoci.UnpackRootfswhich expects standard OCI config mediatype but BuildKit uses:This caused:
config blob is not correct mediatype application/vnd.oci.image.config.v1+jsonBefore (first tenant deployment)
After
Test plan
go test ./lib/images/... ./lib/registry/... ./lib/builds/...)builder_agentNote
Medium Risk
Touches build caching behavior and registry post-push processing; incorrect cache flags or repo matching could reduce cache effectiveness or unintentionally skip conversion for some images.
Overview
Fixes BuildKit registry cache exports to work reliably in ephemeral builders by adding
image-manifest=true(andoci-mediatypes=true) to cache export args for both global/admin and tenant caches.Updates the shared
CacheKey.ExportCacheArg()helper and its tests accordingly, addslib/images/oci_test.goto document the BuildKit cache config mediatype incompatibility, and changes the registry to skip ext4 conversion for pushedcache/*images so cache pushes no longer fail.Written by Cursor Bugbot for commit 1460df9. This will update automatically on new commits. Configure here.