fix: extract container files from OCI tar instead of Docker daemon #296
+335
−42
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 the bug where container extraction fails with "No such image" error when
exportToCache=true(SLSA enabled) and the Docker package has noimage:config.Part of https://linear.app/ona-team/issue/CLC-2009/docker-export-mode-for-slsa-l3-compliance-leeway
Problem
When a Docker package:
image:config (not pushed to registry)exportToCache=true(SLSA L3 enabled)The build creates
image.tarwith OCI layout but extraction tries to get the image from Docker daemon, which fails because the image was never loaded into the daemon.Error:
Affected: monorepo CI -
runner/shared/openssh:dockerpackage buildSolution
Modified
extractImageWithOCILibsImpl()to:image.tarexists (created whenexportToCache=true)Changes
pkg/leeway/container_image.gogithub.com/google/go-containerregistry/pkg/v1/layoutextractImageWithOCILibsImpl()to handle OCI tar extractionextractTar()helper functionpkg/leeway/build_test.goinit()that was hiding bugssetupMockForUnitTests()helper for explicit mockingpkg/leeway/build_integration_test.goTestDockerPackage_OCIExtraction_NoImage_IntegrationTesting
New Integration Test
go test -tags=integration -v ./pkg/leeway \ -run TestDockerPackage_OCIExtraction_NoImage_Integration✅ PASS - Verifies extraction works from OCI tar
Existing Tests
TestDockerPackage_ContainerExtraction_Integration- PASSTestDockerPackage_OCILayout_Determinism_Integration- PASS (determinism preserved)Manual Testing
Tested with monorepo
runner/shared/openssh:docker:SLSA L3 Compatibility
✅ Determinism preserved - OCI layout is unchanged
✅ Cache structure unchanged - Only affects extraction
✅ Provenance unaffected - Generated before extraction
✅ Backward compatible - Falls back to daemon when OCI tar doesn't exist
Why This Wasn't Caught Before
The integration tests on main use a global mock in
init()that intercepts ALL extraction calls, including in integration tests. This means tests passed but the real extraction code was never tested.Evidence: Test output shows
msg="Mock: Extracting container filesystem"This PR removes the global mock and makes it opt-in, so integration tests now test real code.
Checklist
Related
Co-authored-by: Ona no-reply@ona.com