Merge pull request #1529 from tonistiigi/migrate-fix

cache: avoid snapshot migration on shallow refs
v0.8
Tõnis Tiigi 2020-06-14 21:53:06 -07:00 committed by GitHub
commit df35e9818d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 12 deletions

27
cache/migrate_v2.go vendored
View File

@ -205,19 +205,22 @@ func MigrateV2(ctx context.Context, from, to string, cs content.Store, s snapsho
// remove old root labels
for _, item := range byID {
if _, err := s.Update(ctx, snapshots.Info{
Name: getSnapshotID(item),
}, "labels.containerd.io/gc.root"); err != nil {
if !errors.Is(err, errdefs.ErrNotFound) {
return err
}
}
if blob := getBlob(item); blob != "" {
if _, err := cs.Update(ctx, content.Info{
Digest: digest.Digest(blob),
em := getEqualMutable(item)
if em == "" {
if _, err := s.Update(ctx, snapshots.Info{
Name: getSnapshotID(item),
}, "labels.containerd.io/gc.root"); err != nil {
return err
if !errors.Is(err, errdefs.ErrNotFound) {
return err
}
}
if blob := getBlob(item); blob != "" {
if _, err := cs.Update(ctx, content.Info{
Digest: digest.Digest(blob),
}, "labels.containerd.io/gc.root"); err != nil {
return err
}
}
}
}