fix setting uncompressed label on content

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2018-10-08 21:48:55 -07:00
parent ab6a2dc83e
commit 89e8097d4c
4 changed files with 15 additions and 8 deletions

View File

@ -115,7 +115,7 @@ func getDiffPairs(ctx context.Context, contentStore content.Store, snapshotter s
}
diffIDStr, ok := info.Labels[containerdUncompressed]
if !ok {
return nil, errors.Errorf("invalid differ response with no diffID")
return nil, errors.Errorf("invalid differ response with no diffID: %v", descr.Digest)
}
diffIDDigest, err := digest.Parse(diffIDStr)
if err != nil {

View File

@ -107,10 +107,21 @@ func (s *Snapshotter) GetBlob(ctx context.Context, key string) (digest.Digest, d
// Checks that there is a blob in the content store.
// If same blob has already been set then this is a noop.
func (s *Snapshotter) SetBlob(ctx context.Context, key string, diffID, blobsum digest.Digest) error {
_, err := s.opt.Content.Info(ctx, blobsum)
info, err := s.opt.Content.Info(ctx, blobsum)
if err != nil {
return err
}
if _, ok := info.Labels["containerd.io/uncompressed"]; !ok {
labels := map[string]string{
"containerd.io/uncompressed": diffID.String(),
}
if _, err := s.opt.Content.Update(ctx, content.Info{
Digest: blobsum,
Labels: labels,
}, "labels.containerd.io/uncompressed"); err != nil {
return err
}
}
md, _ := s.opt.MetadataStore.Get(key)
v, err := metadata.NewValue(DiffPair{DiffID: diffID, Blobsum: blobsum})

View File

@ -242,7 +242,6 @@ func unpack(ctx context.Context, desc ocispec.Descriptor, cs content.Store, csh
for _, layer := range layers {
labels := map[string]string{
"containerd.io/gc.root": time.Now().UTC().Format(time.RFC3339Nano),
"containerd.io/uncompressed": layer.Diff.Digest.String(),
}
if _, err := rootfs.ApplyLayer(ctx, layer, chain, csh, applier, ctdsnapshot.WithLabels(labels)); err != nil {
return "", err

View File

@ -388,10 +388,7 @@ func (w *Worker) unpack(ctx context.Context, descs []ocispec.Descriptor, s cdsna
var chain []digest.Digest
for _, layer := range layers {
labels := map[string]string{
"containerd.io/uncompressed": layer.Diff.Digest.String(),
}
if _, err := rootfs.ApplyLayer(ctx, layer, chain, s, w.Applier, cdsnapshot.WithLabels(labels)); err != nil {
if _, err := rootfs.ApplyLayer(ctx, layer, chain, s, w.Applier); err != nil {
return nil, err
}
chain = append(chain, layer.Diff.Digest)