Skip to content

Commit

Permalink
Merge pull request #3088 from fuweid/me-cp-2876-release-1.1
Browse files Browse the repository at this point in the history
[release/1.1 backporting] bugfix: unpack should always set the snapshot gc label
  • Loading branch information
crosbymichael authored Mar 11, 2019
2 parents 52bfc9f + 4e69228 commit 95a8d1d
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,22 @@ func (i *image) Unpack(ctx context.Context, snapshotterName string) error {
chain = append(chain, layer.Diff.Digest)
}

if unpacked {
desc, err := i.i.Config(ctx, cs, platforms.Default())
if err != nil {
return err
}
desc, err := i.i.Config(ctx, cs, platforms.Default())
if err != nil {
return err
}

rootfs := identity.ChainID(chain).String()
rootfs := identity.ChainID(chain).String()

cinfo := content.Info{
Digest: desc.Digest,
Labels: map[string]string{
fmt.Sprintf("containerd.io/gc.ref.snapshot.%s", snapshotterName): rootfs,
},
}
if _, err := cs.Update(ctx, cinfo, fmt.Sprintf("labels.containerd.io/gc.ref.snapshot.%s", snapshotterName)); err != nil {
return err
}
cinfo := content.Info{
Digest: desc.Digest,
Labels: map[string]string{
fmt.Sprintf("containerd.io/gc.ref.snapshot.%s", snapshotterName): rootfs,
},
}

return nil
_, err = cs.Update(ctx, cinfo, fmt.Sprintf("labels.containerd.io/gc.ref.snapshot.%s", snapshotterName))
return err
}

func (i *image) getLayers(ctx context.Context, platform string) ([]rootfs.Layer, error) {
Expand Down

0 comments on commit 95a8d1d

Please sign in to comment.