Skip to content

Commit

Permalink
Merge pull request moby#46933 from vvoland/c8d-tag-label-duplicate
Browse files Browse the repository at this point in the history
c8d/tag: Remove duplicate label copy
  • Loading branch information
thaJeztah authored Dec 15, 2023
2 parents 7e1c8a5 + d11a772 commit 1997933
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions daemon/containerd/image_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit 1997933

Please sign in to comment.