Skip to content

Add tag delete API#3427

Merged
milosgajdos merged 5 commits intodistribution:mainfrom
joaodrp:tag-delete
Jun 14, 2021
Merged

Add tag delete API#3427
milosgajdos merged 5 commits intodistribution:mainfrom
joaodrp:tag-delete

Conversation

@joaodrp
Copy link
Copy Markdown
Collaborator

@joaodrp joaodrp commented May 27, 2021

The tag delete API operation has finally made it to the OCI Distribution spec, in v1.0.0 (source). This PR makes the required changes to incorporate such functionality.

Signed-off-by: João Pereira 484633+joaodrp@users.noreply.github.com

@joaodrp joaodrp added feature conformance Related to conformance to distribution specification labels May 27, 2021
Signed-off-by: João Pereira <484633+joaodrp@users.noreply.github.com>
Signed-off-by: João Pereira <484633+joaodrp@users.noreply.github.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 27, 2021

Codecov Report

Merging #3427 (81f081f) into main (d80a63f) will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3427      +/-   ##
==========================================
+ Coverage   56.16%   56.19%   +0.02%     
==========================================
  Files         102      102              
  Lines        7303     7323      +20     
==========================================
+ Hits         4102     4115      +13     
- Misses       2553     2556       +3     
- Partials      648      652       +4     
Impacted Files Coverage Δ
...ibution/distribution/registry/client/repository.go 56.79% <0.00%> (-0.12%) ⬇️
...ribution/distribution/registry/storage/tagstore.go 75.47% <0.00%> (+0.47%) ⬆️
...bution/distribution/registry/handlers/manifests.go 52.50% <0.00%> (+1.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d80a63f...81f081f. Read the comment docs.

if err := repository.Tags(ctx).Tag(ctx, tag, distribution.Descriptor{Digest: dgst}); err != nil {
t.Fatalf("unexpected error tagging manifest: %v", err)
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The manifest was not tagged in this test, so there was no tag to delete...

err = repository.Tags(ctx).Untag(ctx, m.Tag)
if err != nil {
t.Fatalf("unexpected error deleting tag: %v", err)
}
Copy link
Copy Markdown
Collaborator Author

@joaodrp joaodrp May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to delete the tag first and only then the manifest, not otherwise (as the tag would be deleted after deleting the manifest). That's why I'm moving this higher up.

This test was not failing until now because we were ignoring not found errors (see #3427 (comment)).

if err := ts.blobStore.driver.Delete(ctx, tagPath); err != nil {
switch err.(type) {
case storagedriver.PathNotFoundError:
return nil // Untag is idempotent, we don't care if it didn't exist
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer true. We must respond with 404 Not Found if a tag is not found at the API level. So returning the error here and letting the caller decide what to do with it.

@joaodrp joaodrp requested review from milosgajdos and thaJeztah May 27, 2021 23:09
@joaodrp joaodrp mentioned this pull request May 27, 2021
Copy link
Copy Markdown
Member

@milosgajdos milosgajdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I only have one question I'd like to get cleared up.

@milosgajdos milosgajdos added this to the Registry/3.0.0 milestone May 28, 2021
Signed-off-by: João Pereira <484633+joaodrp@users.noreply.github.com>
@milosgajdos milosgajdos requested a review from wy65701436 May 28, 2021 09:26
Signed-off-by: João Pereira <484633+joaodrp@users.noreply.github.com>
Copy link
Copy Markdown
Member

@milosgajdos milosgajdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@milosgajdos milosgajdos requested a review from waynr May 28, 2021 15:52
case distribution.ErrTagUnknown, driver.PathNotFoundError:
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnknown)
default:
imh.Errors = append(imh.Errors, errcode.ErrorCodeUnknown)
Copy link
Copy Markdown
Collaborator

@wy65701436 wy65701436 Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to append the details, errcode.ErrorCodeUnknown.WithDetail(err)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


if imh.Tag != "" {
tagService := imh.Repository.Tags(imh.Context)
if err := tagService.Untag(imh.Context, imh.Tag); err != nil {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add log here? dcontext.GetLogger(imh).Debug("DeleteImageTag")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: João Pereira <484633+joaodrp@users.noreply.github.com>
@milosgajdos milosgajdos requested a review from wy65701436 June 13, 2021 19:55
Copy link
Copy Markdown
Collaborator

@wy65701436 wy65701436 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@antoinetran
Copy link
Copy Markdown

Hi, hem it does not seems to me that this merge is included in 2.8.0.beta1? I looked at the changelog and can't find it. Even https://docs.docker.com/registry/spec/api/#detail does not include the doc modification. ping @milosgajdos maybe? Thank you.

@milosgajdos
Copy link
Copy Markdown
Member

@antoinetran no, it isn't in 2.x. We made a decision to not include anything new in the last 2.x release. You'll have to build of main or pull :edge tag, I'm afraid.

@chethankumar4046
Copy link
Copy Markdown

@milosgajdos @wy65701436 Where can i see documentation about, Delete image by tag. in V2.
Thanks

@milosgajdos
Copy link
Copy Markdown
Member

@chethankumar4046 this PR diff will show you where the docs are. It pays off looking into diffs.

@chethankumar4046
Copy link
Copy Markdown

@milosgajdos I gone through PR But I need more clarification Because i see some open ticket and I tried above method but it deleted my whole image,
When i try to list image i got this output, when i run this api /v2/chethantest/tags/list
{"errors":[{"code":"NAME_UNKNOWN","message":"repository name not known to registry","detail":{"name":"chethantest"}}]}
#2317 (comment)

@ioparaskev
Copy link
Copy Markdown

ioparaskev commented Sep 27, 2024

@milosgajdos this fix doesn't seem to be released currently in any of the 2.x released versions (at least according to the release notes). Is there a plan of releasing it in version 2.x at some point? If yes, I was wondering if there's any optimistic timeline for this. Or if there's a milestone for releasing a stable 3.x version

@milosgajdos
Copy link
Copy Markdown
Member

@milosgajdos this fix doesn't seem to be released currently in any of the 2.x released versions

Correct. 2.x is basically in a maintenance mode at this point.

Or if there's a milestone for releasing a stable 3.x version

The original plan was by the end of this year but as you may have noticed we have 10+ maintainers on this repo and I'm the only one active. Or I was until I gave up on chasing the others, so no ETA.

@ioparaskev
Copy link
Copy Markdown

@milosgajdos this fix doesn't seem to be released currently in any of the 2.x released versions

Correct. 2.x is basically in a maintenance mode at this point.

Or if there's a milestone for releasing a stable 3.x version

The original plan was by the end of this year but as you may have noticed we have 10+ maintainers on this repo and I'm the only one active. Or I was until I gave up on chasing the others, so no ETA.

I see. Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conformance Related to conformance to distribution specification feature

Projects

None yet

7 participants