Skip to content

Commit

Permalink
Merge pull request #1221 from tonistiigi/leases-follow-up
Browse files Browse the repository at this point in the history
cache: follow-up updates to storage leases
  • Loading branch information
tonistiigi authored Oct 22, 2019
2 parents 02adc6b + 1d867eb commit 4f4e030
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cache/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ func (cm *cacheManager) GetByBlob(ctx context.Context, desc ocispec.Descriptor,
chainID := diffID
blobChainID := imagespecidentity.ChainID([]digest.Digest{desc.Digest, diffID})

if _, err := cm.ContentStore.Info(ctx, desc.Digest); err != nil {
return nil, errors.Wrapf(err, "failed to get blob %s", desc.Digest)
if desc.Digest != "" {
if _, err := cm.ContentStore.Info(ctx, desc.Digest); err != nil {
return nil, errors.Wrapf(err, "failed to get blob %s", desc.Digest)
}
}

var p *immutableRef
Expand Down Expand Up @@ -202,11 +204,13 @@ func (cm *cacheManager) GetByBlob(ctx context.Context, desc ocispec.Descriptor,
return nil, errors.Wrapf(err, "failed to add snapshot %s to lease", id)
}

if err := cm.ManagerOpt.LeaseManager.AddResource(ctx, leases.Lease{ID: id}, leases.Resource{
ID: desc.Digest.String(),
Type: "content",
}); err != nil {
return nil, errors.Wrapf(err, "failed to add blob %s to lease", id)
if desc.Digest != "" {
if err := cm.ManagerOpt.LeaseManager.AddResource(ctx, leases.Lease{ID: id}, leases.Resource{
ID: desc.Digest.String(),
Type: "content",
}); err != nil {
return nil, errors.Wrapf(err, "failed to add blob %s to lease", id)
}
}

md, _ := cm.md.Get(id)
Expand Down
3 changes: 3 additions & 0 deletions cache/migrate_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ func MigrateV2(ctx context.Context, from, to string, cs content.Store, s snapsho
if err := v.Unmarshal(&blob); err != nil {
return errors.WithStack(err)
}
if _, err := cs.Info(ctx, digest.Digest(blob.Blobsum)); err != nil {
continue
}
queueDiffID(item, blob.DiffID)
queueBlob(item, blob.Blobsum)
queueMediaType(item, images.MediaTypeDockerSchema2LayerGzip)
Expand Down

0 comments on commit 4f4e030

Please sign in to comment.