From 3b53729fdca3d892b192f184704d67fdc5735bb5 Mon Sep 17 00:00:00 2001 From: Yan Song Date: Thu, 17 Feb 2022 02:51:14 +0000 Subject: [PATCH] Solver: disable inline cache export for nydus compression type Since the nydus image layer does not correspond to the cache records, the inline cache export of nydus image is disabled here. Signed-off-by: Yan Song --- docs/nydus.md | 1 + solver/llbsolver/solver.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/docs/nydus.md b/docs/nydus.md index 04a35c5dd61e2..e47fe7b3cb650 100644 --- a/docs/nydus.md +++ b/docs/nydus.md @@ -25,6 +25,7 @@ buildctl build ... \ - The export of Nydus image and runtime (e.g. [docker](https://github.com/dragonflyoss/image-service/tree/master/contrib/docker-nydus-graphdriver), [containerd](https://github.com/containerd/nydus-snapshotter), etc.) is currently only supported on linux platform. - Nydus image layers cannot be mixed with other compression types in the same image, so the `force-compression=true` option is automatically enabled when exporting both Nydus compression type and other compression types. +- Since the Nydus image layer does not correspond to the cache records, the inline cache export of Nydus image is unsupported. - Specifying a Nydus image as a base image in a Dockerfile is not currently supported (i.e. lazily pull using a Nydus image). ### Other ways to create Nydus images diff --git a/solver/llbsolver/solver.go b/solver/llbsolver/solver.go index 1ffcbcbd5c9dc..bd339fd3faa77 100644 --- a/solver/llbsolver/solver.go +++ b/solver/llbsolver/solver.go @@ -306,6 +306,12 @@ func inlineCache(ctx context.Context, e remotecache.Exporter, res solver.CachedR if efl, ok := e.(interface { ExportForLayers(context.Context, []digest.Digest) ([]byte, error) }); ok { + if compressionopt.Type == compression.NydusBlob { + // Since the nydus image layer does not correspond to the cache records, + // the inline cache export of nydus image is disabled here. + return nil, errors.Errorf("inline cache with %s compression is unsupported", compressionopt.Type) + } + workerRef, ok := res.Sys().(*worker.WorkerRef) if !ok { return nil, errors.Errorf("invalid reference: %T", res.Sys())