Skip to content

Commit

Permalink
pull: fix second cachekey for schema1
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed Feb 26, 2019
1 parent 86aba5a commit 37567fc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions source/containerimage/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}

0 comments on commit 37567fc

Please sign in to comment.