From e376b78cb5139d83bb3158bd2daf038b6051d999 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Fri, 31 Aug 2018 01:40:41 +0000 Subject: [PATCH] builder: fix pruning all cache Signed-off-by: Tibor Vass (cherry picked from commit d47435a004e36531a594cd2636dddaff61a5f4d0) Signed-off-by: Tibor Vass Upstream-commit: d2c316364225cd6bdf1581d11f370e0d159ad362 Component: engine --- .../builder/builder-next/adapters/containerimage/pull.go | 9 +++++++++ components/engine/builder/builder-next/controller.go | 2 ++ 2 files changed, 11 insertions(+) diff --git a/components/engine/builder/builder-next/adapters/containerimage/pull.go b/components/engine/builder/builder-next/adapters/containerimage/pull.go index e56efd5134..f187f5c16f 100644 --- a/components/engine/builder/builder-next/adapters/containerimage/pull.go +++ b/components/engine/builder/builder-next/adapters/containerimage/pull.go @@ -516,6 +516,15 @@ func (p *puller) Snapshot(ctx context.Context) (cache.ImmutableRef, error) { return nil, err } + // TODO: handle windows layers for cross platform builds + + if p.src.RecordType != "" && cache.GetRecordType(ref) == "" { + if err := cache.SetRecordType(ref, p.src.RecordType); err != nil { + ref.Release(context.TODO()) + return nil, err + } + } + return ref, nil } diff --git a/components/engine/builder/builder-next/controller.go b/components/engine/builder/builder-next/controller.go index 48e74cb851..1d0ed2d496 100644 --- a/components/engine/builder/builder-next/controller.go +++ b/components/engine/builder/builder-next/controller.go @@ -72,6 +72,8 @@ func newController(rt http.RoundTripper, opt Opt) (*control.Controller, error) { cm, err := cache.NewManager(cache.ManagerOpt{ Snapshotter: snapshotter, MetadataStore: md, + // TODO: implement PruneRefChecker to correctly mark cache objects as "Shared" + PruneRefChecker: nil, }) if err != nil { return nil, err