commit
b9657e33c6
|
@ -1266,10 +1266,6 @@ func TestSharingCompressionVariant(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
defer cleanup()
|
||||
|
||||
ctx, done, err := leaseutil.WithLease(ctx, co.lm, leaseutil.MakeTemporary)
|
||||
require.NoError(t, err)
|
||||
defer done(context.TODO())
|
||||
|
||||
allCompressions := []compression.Type{compression.Uncompressed, compression.Gzip, compression.Zstd, compression.EStargz}
|
||||
|
||||
do := func(test func(testCaseSharingCompressionVariant)) {
|
||||
|
@ -1382,7 +1378,7 @@ func testSharingCompressionVariant(ctx context.Context, t *testing.T, co *cmOut,
|
|||
require.NoError(t, err)
|
||||
defer aRef.Release(ctx)
|
||||
var bDesc ocispecs.Descriptor
|
||||
for _, compressionType := range testCase.aVariants {
|
||||
for _, compressionType := range append([]compression.Type{testCase.a}, testCase.aVariants...) {
|
||||
remotes, err := aRef.GetRemotes(ctx, true, config.RefConfig{Compression: compression.New(compressionType).SetForce(true)}, false, nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(remotes))
|
||||
|
@ -1395,7 +1391,7 @@ func testSharingCompressionVariant(ctx context.Context, t *testing.T, co *cmOut,
|
|||
bRef, err := cm.GetByBlob(ctx, bDesc, nil, descHandlers)
|
||||
require.NoError(t, err)
|
||||
defer bRef.Release(ctx)
|
||||
for _, compressionType := range testCase.bVariants {
|
||||
for _, compressionType := range append([]compression.Type{testCase.b}, testCase.bVariants...) {
|
||||
remotes, err := bRef.GetRemotes(ctx, true, config.RefConfig{Compression: compression.New(compressionType).SetForce(true)}, false, nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(remotes))
|
||||
|
|
|
@ -308,6 +308,10 @@ func (cr *cacheRecord) viewLeaseID() string {
|
|||
return cr.ID() + "-view"
|
||||
}
|
||||
|
||||
func (cr *cacheRecord) compressionVariantsLeaseID() string {
|
||||
return cr.ID() + "-variants"
|
||||
}
|
||||
|
||||
func (cr *cacheRecord) viewSnapshotID() string {
|
||||
return cr.getSnapshotID() + "-view"
|
||||
}
|
||||
|
@ -438,6 +442,11 @@ func (cr *cacheRecord) remove(ctx context.Context, removeSnapshot bool) error {
|
|||
}); err != nil && !errdefs.IsNotFound(err) {
|
||||
return errors.Wrapf(err, "failed to delete lease for %s", cr.ID())
|
||||
}
|
||||
if err := cr.cm.LeaseManager.Delete(ctx, leases.Lease{
|
||||
ID: cr.compressionVariantsLeaseID(),
|
||||
}); err != nil && !errdefs.IsNotFound(err) {
|
||||
return errors.Wrapf(err, "failed to delete compression variant lease for %s", cr.ID())
|
||||
}
|
||||
}
|
||||
if err := cr.cm.MetadataStore.Clear(cr.ID()); err != nil {
|
||||
return errors.Wrapf(err, "failed to delete metadata of %s", cr.ID())
|
||||
|
@ -699,6 +708,19 @@ const (
|
|||
// this ref. This doesn't record the blob to the cache record (i.e. the passed blob can't
|
||||
// be acquired through getBlob). Use setBlob for that purpose.
|
||||
func (sr *immutableRef) linkBlob(ctx context.Context, desc ocispecs.Descriptor) error {
|
||||
if _, err := sr.cm.LeaseManager.Create(ctx, func(l *leases.Lease) error {
|
||||
l.ID = sr.compressionVariantsLeaseID()
|
||||
// do not make it flat lease to allow linking blobs using gc label
|
||||
return nil
|
||||
}); err != nil && !errdefs.IsAlreadyExists(err) {
|
||||
return err
|
||||
}
|
||||
if err := sr.cm.LeaseManager.AddResource(ctx, leases.Lease{ID: sr.compressionVariantsLeaseID()}, leases.Resource{
|
||||
ID: desc.Digest.String(),
|
||||
Type: "content",
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
cs := sr.cm.ContentStore
|
||||
blobDigest := sr.getBlob()
|
||||
info, err := cs.Info(ctx, blobDigest)
|
||||
|
|
Loading…
Reference in New Issue