add check for FakeDeleteMarker in case of versioned bucket#7948
Merged
add check for FakeDeleteMarker in case of versioned bucket#7948
Conversation
bentsku
commented
Mar 24, 2023
| moto_bucket: FakeBucket, | ||
| key: ObjectKey, | ||
| version_id: str = None, | ||
| raise_if_delete_marker_method: Literal["GET", "PUT"] = None, |
Contributor
Author
There was a problem hiding this comment.
I really dislike this, but this is a quick fix for now and would need to be revisited to better implement versioning.
0907f6b to
8d0836b
Compare
thrau
approved these changes
Mar 24, 2023
Member
thrau
left a comment
There was a problem hiding this comment.
great find! and looks like a pretty reasonable fix for now! 🏅 for all the snapshot tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While looking at the tests run, I realised we were encountering issue when doing test cleanup.
Trace:
After some reproductions, I could reproduce the issue when the bucket is versioned, which we, it turns out, don't support very well. While migrating the S3 provider, we did not account very much for the concept of
VersionId, and we did not have tests covering it (not a single operation was done withVersionIdparameter).So I've added some checks and fixed some direct usages of moto
FakeKeyobject which can beFakeDeleteMarker, a case we didn't account for. We can fix a lot more when using versioned bucket, but at least now we shouldn't raise directAttributeError.Concerning notifications, we do not support
s3:ObjectRemoved:DeleteMarkerCreatedat the moment and we will send as3:ObjectRemoved:Deleteinstead, but this will need a bit of refactoring in the notification handling (in the map determining the service operation, it would depend if the bucket is versioned or not and if we delete a key or delete a key version).I guess we can see this as a bandaid, we don't implement versioned buckets in a better way for now (except for
PutObjectAcl), but at least we don't raise exceptions linked to that. We will need to come back to this to better support the use case with some usage numbers.Sources:
https://docs.aws.amazon.com/AmazonS3/latest/userguide/DeleteMarker.html
https://docs.aws.amazon.com/AmazonS3/latest/userguide/DeletingObjectVersions.html
https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-how-to-event-types-and-destinations.html#supported-notification-event-types