From 3a270318fcf603907017b4ab1434a572d56a0cc2 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Wed, 24 Feb 2021 01:11:17 -0800 Subject: [PATCH] allow skipping empty layer detection on cache export Signed-off-by: Tonis Tiigi (cherry picked from commit 29af1397e204096b4b1a9e4a6dcf86f47028d573) Signed-off-by: Tibor Vass --- cache/remotecache/v1/utils.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cache/remotecache/v1/utils.go b/cache/remotecache/v1/utils.go index fc494aa5..9531675e 100644 --- a/cache/remotecache/v1/utils.go +++ b/cache/remotecache/v1/utils.go @@ -10,6 +10,10 @@ import ( "github.com/pkg/errors" ) +// EmptyLayerRemovalSupported defines if implementation supports removal of empty layers. Buildkit image exporter +// removes empty layers, but moby layerstore based implementation does not. +var EmptyLayerRemovalSupported = true + // sortConfig sorts the config structure to make sure it is deterministic func sortConfig(cc *CacheConfig) { type indexedLayer struct { @@ -239,7 +243,7 @@ func marshalRemote(r *solver.Remote, state *marshalState) string { } desc := r.Descriptors[len(r.Descriptors)-1] - if desc.Digest == exptypes.EmptyGZLayer { + if desc.Digest == exptypes.EmptyGZLayer && EmptyLayerRemovalSupported { return parentID }