Skip to content

Commit d608e3d

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]>
1 parent 7833fb4 commit d608e3d

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
@@ -25,7 +25,6 @@ import (
2525
"github.com/containerd/containerd/images"
2626
"github.com/containerd/containerd/platforms"
2727
"github.com/containerd/containerd/rootfs"
28-
"github.com/containerd/containerd/snapshots"
2928
digest "github.com/opencontainers/go-digest"
3029
"github.com/opencontainers/image-spec/identity"
3130
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -124,15 +123,25 @@ func (i *image) Unpack(ctx context.Context, snapshotterName string) error {
124123
unpacked bool
125124
)
126125
for _, layer := range layers {
127-
labels := map[string]string{
128-
"containerd.io/uncompressed": layer.Diff.Digest.String(),
129-
}
130-
131-
unpacked, err = rootfs.ApplyLayer(ctx, layer, chain, sn, a, snapshots.WithLabels(labels))
126+
unpacked, err = rootfs.ApplyLayer(ctx, layer, chain, sn, a)
132127
if err != nil {
133128
return err
134129
}
135130

131+
if unpacked {
132+
// Set the uncompressed label after the uncompressed
133+
// digest has been verified through apply.
134+
cinfo := content.Info{
135+
Digest: layer.Blob.Digest,
136+
Labels: map[string]string{
137+
"containerd.io/uncompressed": layer.Diff.Digest.String(),
138+
},
139+
}
140+
if _, err := cs.Update(ctx, cinfo, "labels.containerd.io/uncompressed"); err != nil {
141+
return err
142+
}
143+
}
144+
136145
chain = append(chain, layer.Diff.Digest)
137146
}
138147

0 commit comments

Comments
 (0)