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

[Proposal] RemoveObject & RemoveObjects to return more info about successful deletion #1407

Closed
vadmeste opened this issue Nov 9, 2020 · 14 comments

Comments

@vadmeste
Copy link
Member

vadmeste commented Nov 9, 2020

Currently RemoveObject() and RemoveObjects() only return errors for failed deletions.

However, S3 spec returns two information with successful deletion:
x-amz-version-id
x-amz-delete-marker

which could be useful to have them.

For example, mc wants to show a delete marker is added in a versioning bucket instead of removed message.

@harshavardhana
Copy link
Member

@vadmeste is this fixed?

@vadmeste
Copy link
Member Author

@vadmeste is this fixed?

No, this is not fixed and this needs a major version bump since RemoveObject() needs to return another additional result (or we add a new API ?)

@harshavardhana
Copy link
Member

@vadmeste is this fixed?

No, this is not fixed and this needs a major version bump since RemoveObject() needs to return another additional result (or we add a new API ?)

We can do a version bump since there is another PR that is attempting to do version bump as well

@vadmeste
Copy link
Member Author

API changes for RemoveObjects:

Before:

func (c Client) RemoveObjects(ctx context.Context, bucketName string, objectsCh <-chan ObjectInfo, opts RemoveObjectsOptions) <-chan RemoveObjectError {

After:

func (c Client) RemoveObjects(ctx context.Context, bucketName string, objectsCh <-chan ObjectInfo, opts RemoveObjectsOptions) <-chan RemoveObjectResult {

Before we were only returning errors, now we return successful deletion as well in the returned channel, for that RemoveObjectError is renamed to RemoveObjectResult.

type RemoveObjectResult struct {
        ObjectName      string
        ObjectVersionID string

        DeleteMarker          bool
        DeleteMarkerVersionID string

        Err error
}

I added DeleteMarker & DeleteMarkerVersionID in RemoveObjectResult{}, and I renamed VersionID to ObjectVersionID

API changes for RemoveObject:

Before:

func (c Client) RemoveObject(ctx context.Context, bucketName, objectName string, opts RemoveObjectOptions) error {

After:

func (c Client) RemoveObject(ctx context.Context, bucketName, objectName string, opts RemoveObjectOptions) RemoveObjectResult {

@harshavardhana
Copy link
Member

I think we should deprecate this API, we only need RemoveObjects() AFAICS.

func (c Client) RemoveObject(ctx context.Context, bucketName, objectName string, opts RemoveObjectOptions) RemoveObjectResult {

@vadmeste
Copy link
Member Author

I think we should deprecate this API, we only need RemoveObjects() AFAICS.

yeah we can do that, but the code will be little "ugly" for users who want to delete only one object:

        objectsCh := make(chan minio.ObjectInfo, 1)
        objectsCh <- minio.ObjectInfo{Key: "testobject"}
        close(objectsCh)
        resultCh := s3Client.RemoveObjects(context.Background(), "my-bucketname", objectsCh, minio.RemoveObjectsOptions{})
        for r := range resultCh {
                if r.Err != nil {
                        log.Fatalln("Failed to remove " + r.ObjectName + ", error: " + r.Err.Error())
                }
        }

@klauspost
Copy link
Contributor

Yeah, a single delete option is much nicer API-wise.

@vadmeste
Copy link
Member Author

@harshavardhana maybe we can avoid deprecating and keep the API as it is for now. Any user who wants more information about delete-marker & delete-marker-version-id will have to use DeleteObjects()

@harshavardhana
Copy link
Member

yeah we can do that, but the code will be little "ugly" for users who want to delete only one object:

It's very rare that users only have to delete one object and we are providing a proper streaming approach. It is not a big deal to use only RemoveObjects() API

@harshavardhana maybe we can avoid deprecating and keep the API as it is for now. Any user who wants more information about delete-marker & delete-marker-version-id will have to use DeleteObjects()

We can't add two different APIs unfortunately.

@vadmeste
Copy link
Member Author

We can't add two different APIs unfortunately.

Yes, I am not adding any new API. What I am saying is, we keep DeleteObject() as it is but not deprecate it and we break DeleteObjects() to return delete marker information

@harshavardhana
Copy link
Member

Yes, I am not adding any new API. What I am saying is, we keep DeleteObject() as it is but not deprecate it and we break DeleteObjects() to return delete marker information

No, if we are breaking just remove older ones we don't need a single deleteObject() - for that we can use core.DeleteObject() - higher level APIs are meant for more mc like tools.

@vadmeste
Copy link
Member Author

What about removing RemoveObject but simplifying removing one object using a new API, so it will look like this:

 resultCh := s3Client.RemoveObjects(
         context.Background(), 
         "my-bucketname", 
          minio.GenObjectsList([]minio.ObjectInfo{Key: "testobject"}), 
          minio.RemoveObjectsOptions{},
)

@andreykeen
Copy link

API changes for RemoveObjects:

Before:

func (c Client) RemoveObjects(ctx context.Context, bucketName string, objectsCh <-chan ObjectInfo, opts RemoveObjectsOptions) <-chan RemoveObjectError {

After:

func (c Client) RemoveObjects(ctx context.Context, bucketName string, objectsCh <-chan ObjectInfo, opts RemoveObjectsOptions) <-chan RemoveObjectResult {

Before we were only returning errors, now we return successful deletion as well in the returned channel, for that RemoveObjectError is renamed to RemoveObjectResult.

type RemoveObjectResult struct {
        ObjectName      string
        ObjectVersionID string

        DeleteMarker          bool
        DeleteMarkerVersionID string

        Err error
}

I added DeleteMarker & DeleteMarkerVersionID in RemoveObjectResult{}, and I renamed VersionID to ObjectVersionID

API changes for RemoveObject:

Before:

func (c Client) RemoveObject(ctx context.Context, bucketName, objectName string, opts RemoveObjectOptions) error {

After:

func (c Client) RemoveObject(ctx context.Context, bucketName, objectName string, opts RemoveObjectOptions) RemoveObjectResult {

Are you planning to release a new version with these changes in the near future?

@harshavardhana
Copy link
Member

This enhancement is not needed refer PR #1456

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

No branches or pull requests

4 participants