-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cache: don't skip unlazy without blob check
Signed-off-by: Tonis Tiigi <[email protected]>
- Loading branch information
1 parent
12bbf07
commit dfcb140
Showing
2 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,6 +206,7 @@ func TestIntegration(t *testing.T) { | |
testLLBMountPerformance, | ||
testClientCustomGRPCOpts, | ||
testMultipleRecordsWithSameLayersCacheImportExport, | ||
testSnapshotWithMultipleBlobs, | ||
testExportLocalNoPlatformSplit, | ||
testExportLocalNoPlatformSplitOverwrite, | ||
) | ||
|
@@ -5494,6 +5495,148 @@ func testMultipleRecordsWithSameLayersCacheImportExport(t *testing.T, sb integra | |
ensurePruneAll(t, c, sb) | ||
} | ||
|
||
// moby/buildkit#3809 | ||
func testSnapshotWithMultipleBlobs(t *testing.T, sb integration.Sandbox) { | ||
workers.CheckFeatureCompat(t, sb, workers.FeatureOCIExporter) | ||
c, err := New(sb.Context(), sb.Address()) | ||
require.NoError(t, err) | ||
defer c.Close() | ||
|
||
// build two images with same layer but different compressed blobs | ||
|
||
registry, err := sb.NewRegistry() | ||
if errors.Is(err, integration.ErrRequirements) { | ||
t.Skip(err.Error()) | ||
} | ||
require.NoError(t, err) | ||
|
||
now := time.Now() | ||
|
||
st := llb.Scratch().File(llb.Copy(llb.Image("alpine"), "/", "/alpine/", llb.WithCreatedTime(now))) | ||
|
||
def, err := st.Marshal(sb.Context()) | ||
require.NoError(t, err) | ||
|
||
name1 := registry + "/multiblobtest1/image:latest" | ||
|
||
_, err = c.Solve(sb.Context(), def, SolveOpt{ | ||
Exports: []ExportEntry{ | ||
{ | ||
Type: "image", | ||
Attrs: map[string]string{ | ||
"name": name1, | ||
"push": "true", | ||
"compression-level": "0", | ||
}, | ||
}, | ||
}, | ||
}, nil) | ||
require.NoError(t, err) | ||
|
||
ensurePruneAll(t, c, sb) | ||
|
||
st = st.File(llb.Mkfile("test", 0600, []byte("test"))) // extra layer so we don't get a cache match based on image config rootfs only | ||
|
||
def, err = st.Marshal(sb.Context()) | ||
require.NoError(t, err) | ||
|
||
name2 := registry + "/multiblobtest2/image:latest" | ||
|
||
_, err = c.Solve(sb.Context(), def, SolveOpt{ | ||
Exports: []ExportEntry{ | ||
{ | ||
Type: "image", | ||
Attrs: map[string]string{ | ||
"name": name2, | ||
"push": "true", | ||
"compression-level": "9", | ||
}, | ||
}, | ||
}, | ||
}, nil) | ||
require.NoError(t, err) | ||
|
||
ensurePruneAll(t, c, sb) | ||
|
||
// first build with first image | ||
destDir := t.TempDir() | ||
|
||
out1 := filepath.Join(destDir, "out1.tar") | ||
outW1, err := os.Create(out1) | ||
require.NoError(t, err) | ||
|
||
st = llb.Image(name1).File(llb.Mkfile("test", 0600, []byte("test1"))) | ||
|
||
def, err = st.Marshal(sb.Context()) | ||
require.NoError(t, err) | ||
|
||
_, err = c.Solve(sb.Context(), def, SolveOpt{ | ||
Exports: []ExportEntry{ | ||
{ | ||
Type: ExporterOCI, // make sure to export so blobs need to be loaded | ||
Output: fixedWriteCloser(outW1), | ||
}, | ||
}, | ||
}, nil) | ||
require.NoError(t, err) | ||
|
||
// make sure second image does not cause any errors | ||
out2 := filepath.Join(destDir, "out2.tar") | ||
outW2, err := os.Create(out2) | ||
require.NoError(t, err) | ||
|
||
st = llb.Image(name2).File(llb.Mkfile("test", 0600, []byte("test2"))) | ||
|
||
def, err = st.Marshal(sb.Context()) | ||
require.NoError(t, err) | ||
|
||
_, err = c.Solve(sb.Context(), def, SolveOpt{ | ||
FrontendAttrs: map[string]string{ | ||
"attest:sbom": "", | ||
}, | ||
Exports: []ExportEntry{ | ||
{ | ||
Type: ExporterOCI, // make sure to export so blobs need to be loaded | ||
Output: fixedWriteCloser(outW2), | ||
}, | ||
}, | ||
}, nil) | ||
require.NoError(t, err) | ||
|
||
// extra validation that we did get different layer blobs | ||
dt, err := os.ReadFile(out1) | ||
require.NoError(t, err) | ||
|
||
m, err := testutil.ReadTarToMap(dt, false) | ||
require.NoError(t, err) | ||
|
||
var index ocispecs.Index | ||
err = json.Unmarshal(m["index.json"].Data, &index) | ||
require.NoError(t, err) | ||
|
||
var mfst ocispecs.Manifest | ||
err = json.Unmarshal(m["blobs/sha256/"+index.Manifests[0].Digest.Hex()].Data, &mfst) | ||
require.NoError(t, err) | ||
|
||
dt, err = os.ReadFile(out2) | ||
require.NoError(t, err) | ||
|
||
m, err = testutil.ReadTarToMap(dt, false) | ||
require.NoError(t, err) | ||
|
||
err = json.Unmarshal(m["index.json"].Data, &index) | ||
require.NoError(t, err) | ||
|
||
err = json.Unmarshal(m["blobs/sha256/"+index.Manifests[0].Digest.Hex()].Data, &index) | ||
require.NoError(t, err) | ||
|
||
var mfst2 ocispecs.Manifest | ||
err = json.Unmarshal(m["blobs/sha256/"+index.Manifests[0].Digest.Hex()].Data, &mfst2) | ||
require.NoError(t, err) | ||
|
||
require.NotEqual(t, mfst.Layers[0].Digest, mfst2.Layers[0].Digest) | ||
Check failure on line 5637 in client/client_test.go GitHub Actions / test / run (containerd-rootless, ./client ./cmd/buildctl ./worker/containerd ./solver ./frontend, integr...Failed: client/TestIntegration/TestSnapshotWithMultipleBlobs/worker=containerd-rootless
|
||
} | ||
|
||
func testExportLocalNoPlatformSplit(t *testing.T, sb integration.Sandbox) { | ||
workers.CheckFeatureCompat(t, sb, workers.FeatureOCIExporter, workers.FeatureMultiPlatform) | ||
c, err := New(sb.Context(), sb.Address()) | ||
|