Skip to content

Commit 457c658

Browse files
committed
Fix label being put on snapshot instead of content
The uncompressed label should be placed on content instead of snapshots. Currently the uncompressed label is getting passed into as a label option for apply, which is used to commit snapshots. The content is already committed, but after apply the uncompressed diff digest is verified and can be reliably used to update the content with the label. Signed-off-by: Derek McGowan <[email protected]> (cherry picked from commit d608e3d) Signed-off-by: Derek McGowan <[email protected]>
1 parent bde0036 commit 457c658

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

image.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/containerd/containerd/images"
1010
"github.com/containerd/containerd/platforms"
1111
"github.com/containerd/containerd/rootfs"
12-
"github.com/containerd/containerd/snapshots"
1312
digest "github.com/opencontainers/go-digest"
1413
"github.com/opencontainers/image-spec/identity"
1514
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -108,15 +107,25 @@ func (i *image) Unpack(ctx context.Context, snapshotterName string) error {
108107
unpacked bool
109108
)
110109
for _, layer := range layers {
111-
labels := map[string]string{
112-
"containerd.io/uncompressed": layer.Diff.Digest.String(),
113-
}
114-
115-
unpacked, err = rootfs.ApplyLayer(ctx, layer, chain, sn, a, snapshots.WithLabels(labels))
110+
unpacked, err = rootfs.ApplyLayer(ctx, layer, chain, sn, a)
116111
if err != nil {
117112
return err
118113
}
119114

115+
if unpacked {
116+
// Set the uncompressed label after the uncompressed
117+
// digest has been verified through apply.
118+
cinfo := content.Info{
119+
Digest: layer.Blob.Digest,
120+
Labels: map[string]string{
121+
"containerd.io/uncompressed": layer.Diff.Digest.String(),
122+
},
123+
}
124+
if _, err := cs.Update(ctx, cinfo, "labels.containerd.io/uncompressed"); err != nil {
125+
return err
126+
}
127+
}
128+
120129
chain = append(chain, layer.Diff.Digest)
121130
}
122131

0 commit comments

Comments
 (0)