Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support delete a blob from a remote registry #493

Merged
merged 8 commits into from
Sep 15, 2022

Conversation

lizMSFT
Copy link
Contributor

@lizMSFT lizMSFT commented Aug 15, 2022

Add a command to delete a blob from a remote registry

Resolves: #474
Signed-off-by: Zoey Li zoeyli@microsoft.com

cmd/oras/blob/cmd.go Outdated Show resolved Hide resolved
@shizhMSFT shizhMSFT modified the milestones: v0.14.0, v0.15.0 Aug 15, 2022
@lizMSFT lizMSFT force-pushed the liz/474 branch 2 times, most recently from 5b252e4 to 7f681c7 Compare August 16, 2022 06:48
Copy link
Member

@Wwwsylvia Wwwsylvia left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@qweeah qweeah left a comment

Choose a reason for hiding this comment

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

We need to wrap all the err returning from deleteBlob() to make error message more readable to user.

e.g.

if err = repo.Delete(ctx, desc); err != nil {
    return fmt.Errorf("failed to delete %s: %w", opts.targetRef, err)
}

cmd/oras/blob/delete.go Outdated Show resolved Hide resolved
cmd/oras/blob/delete.go Outdated Show resolved Hide resolved
cmd/oras/blob/delete.go Outdated Show resolved Hide resolved
cmd/oras/blob/delete.go Outdated Show resolved Hide resolved
cmd/oras/blob/delete.go Show resolved Hide resolved
cmd/oras/blob/delete.go Outdated Show resolved Hide resolved
cmd/oras/blob/delete.go Outdated Show resolved Hide resolved
cmd/oras/blob/delete.go Outdated Show resolved Hide resolved
cmd/oras/blob/delete.go Outdated Show resolved Hide resolved
@shizhMSFT
Copy link
Contributor

It's better to have a confirmation before deletion. Also, it is good to display a warning on the implication of deleting a blob.

Again, have you tried with those delete-disabled registries? What does the error message look like?

Signed-off-by: Zoey Li <zoeyli@microsoft.com>
Signed-off-by: Zoey Li <zoeyli@microsoft.com>
@lizMSFT
Copy link
Contributor Author

lizMSFT commented Sep 13, 2022

Hi @shizhMSFT,

I tried delete a blob from a delete-disabled registry, below is the current error message:
Error: failed to delete localhost:12900/0818hello@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855: DELETE "http://localhost:12900/v2/0818hello/blobs/sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855": unexpected status code 405: unsupported: The operation is unsupported.
I'm wondering if we should provide more specific error message for this kind of error? thanks

cc @yuehaoliang-microsoft

@codecov-commenter
Copy link

codecov-commenter commented Sep 13, 2022

Codecov Report

Merging #493 (d057c64) into main (551aca4) will decrease coverage by 2.53%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #493      +/-   ##
==========================================
- Coverage   71.37%   68.83%   -2.54%     
==========================================
  Files          12       13       +1     
  Lines         489      507      +18     
==========================================
  Hits          349      349              
- Misses        112      130      +18     
  Partials       28       28              
Impacted Files Coverage Δ
cmd/oras/internal/option/confirmation.go 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@yuehaoliang
Copy link
Contributor

yuehaoliang commented Sep 13, 2022

Hi @shizhMSFT,

I tried delete a blob from a delete-disabled registry, below is the current error message: Error: failed to delete localhost:12900/0818hello@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855: DELETE "http://localhost:12900/v2/0818hello/blobs/sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855": unexpected status code 405: unsupported: The operation is unsupported. I'm wondering if we should provide more specific error message for this kind of error? thanks

cc @yuehaoliang-microsoft

I've seen this error when I previously used oras/distribution without enabling the deletion. Maybe we can have a more clear error message to let users know it the registry server side which they use doesn't accept the delete operation. At least, unexpected status code 405: unsupported: The operation is unsupported this message tells users their deletion is unsuccessful.

Signed-off-by: Zoey Li <zoeyli@microsoft.com>
cmd/oras/internal/option/confirmation.go Outdated Show resolved Hide resolved
cmd/oras/blob/delete.go Show resolved Hide resolved
Signed-off-by: Zoey Li <zoeyli@microsoft.com>
cmd/oras/blob/delete.go Show resolved Hide resolved
cmd/oras/blob/delete.go Show resolved Hide resolved
@shizhMSFT
Copy link
Contributor

shizhMSFT commented Sep 15, 2022

Hi @shizhMSFT,
I tried delete a blob from a delete-disabled registry, below is the current error message: Error: failed to delete localhost:12900/0818hello@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855: DELETE "http://localhost:12900/v2/0818hello/blobs/sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855": unexpected status code 405: unsupported: The operation is unsupported. I'm wondering if we should provide more specific error message for this kind of error? thanks
cc @yuehaoliang-microsoft

I've seen this error when I previously used oras/distribution without enabling the deletion. Maybe we can have a more clear error message to let users know it the registry server side which they use doesn't accept the delete operation. At least, unexpected status code 405: unsupported: The operation is unsupported this message tells users their deletion is unsuccessful.

@Wwwsylvia, we should support this in the oras-go: oras-project/oras-go#317.

Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@shizhMSFT shizhMSFT merged commit 8b357bf into oras-project:main Sep 15, 2022
TerryHowe pushed a commit to TerryHowe/oras that referenced this pull request Feb 2, 2023
Signed-off-by: Zoey Li <zoeyli@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command to delete a blob from a remote registry
6 participants