From 37567fc826e994e403603ca1d4b950977d4c4981 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 25 Feb 2019 17:16:12 -0800 Subject: [PATCH] pull: fix second cachekey for schema1 Signed-off-by: Tonis Tiigi --- source/containerimage/pull.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/containerimage/pull.go b/source/containerimage/pull.go index 834e6415..88d6de28 100644 --- a/source/containerimage/pull.go +++ b/source/containerimage/pull.go @@ -159,14 +159,18 @@ func (p *puller) CacheKey(ctx context.Context, index int) (string, bool, error) } _, dt, err := imageutil.Config(ctx, ref.String(), p.Resolver, p.ContentStore, &p.Platform) if err != nil { - // this happens on schema1 images + return "", false, err + } + + k := cacheKeyFromConfig(dt).String() + if k == "" { k, err := mainManifestKey(ctx, desc, p.Platform) if err != nil { return "", false, err } return k.String(), true, nil } - return cacheKeyFromConfig(dt).String(), true, nil + return k, true, nil } func (p *puller) Snapshot(ctx context.Context) (cache.ImmutableRef, error) { @@ -225,8 +229,8 @@ func cacheKeyFromConfig(dt []byte) digest.Digest { if err != nil { return digest.FromBytes(dt) } - if img.RootFS.Type != "layers" { - return digest.FromBytes(dt) + if img.RootFS.Type != "layers" || len(img.RootFS.DiffIDs) == 0 { + return "" } return identity.ChainID(img.RootFS.DiffIDs) }