From d11a77208050d4eaa3b0509acf41fea98851fa80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Wed, 13 Dec 2023 12:41:28 +0100 Subject: [PATCH] c8d/tag: Remove duplicate label copy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No need to copy the parent label from the source dangling image, because it will already be copied from the source image. Signed-off-by: Paweł Gronowski --- daemon/containerd/image_tag.go | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/daemon/containerd/image_tag.go b/daemon/containerd/image_tag.go index 8050af2daadeb..f127ac913bbbb 100644 --- a/daemon/containerd/image_tag.go +++ b/daemon/containerd/image_tag.go @@ -65,29 +65,8 @@ func (i *ImageService) TagImage(ctx context.Context, imageID image.ID, newTag re defer i.LogImageEvent(imageID.String(), reference.FamiliarString(newTag), events.ActionTag) - // The tag succeeded, check if the source image is dangling - sourceDanglingImg, err := is.Get(compatcontext.WithoutCancel(ctx), danglingImageName(targetImage.Target.Digest)) - if err != nil { - if !cerrdefs.IsNotFound(err) { - logger.WithError(err).Warn("unexpected error when checking if source image is dangling") - } - - return nil - } - - builderLabel, ok := sourceDanglingImg.Labels[imageLabelClassicBuilderParent] - if ok { - newImg.Labels = map[string]string{ - imageLabelClassicBuilderParent: builderLabel, - } - - if _, err := is.Update(compatcontext.WithoutCancel(ctx), newImg, "labels"); err != nil { - logger.WithError(err).Warnf("failed to set %s label on the newly tagged image", imageLabelClassicBuilderParent) - } - } - // Delete the source dangling image, as it's no longer dangling. - if err := is.Delete(compatcontext.WithoutCancel(ctx), sourceDanglingImg.Name); err != nil { + if err := is.Delete(compatcontext.WithoutCancel(ctx), danglingImageName(targetImage.Target.Digest)); err != nil { logger.WithError(err).Warn("unexpected error when deleting dangling image") }