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

migrate S3 notifications to ASF #6903

Merged
merged 3 commits into from Sep 30, 2022
Merged

migrate S3 notifications to ASF #6903

merged 3 commits into from Sep 30, 2022

Conversation

steffyP
Copy link
Member

@steffyP steffyP commented Sep 20, 2022

This PR contains S3 bucket notifications for:

  • SQS
  • SNS
  • Lambda (Cloudfunctions)
  • Event Bridge

Implemented:

Following events are covered (also by existing tests):

  • s3_ObjectCreated_Put
  • s3_ObjectCreated_Copy
  • s3_ObjectCreated_CompleteMultipartUpload
  • s3_ObjectRemoved_Delete
  • s3_ObjectTagging_Put
  • s3_ObjectTagging_Delete

Other implementation:

  • Filters
  • verification for filters, destination configuration
  • added tests, refactored existing tests

Known Issues + Future work:

  • InvalidArgument Error: marked a few TODOs here, because in another PR we already have a batch for that missing Exception
  • xray-feature: no tests yet for lambda + SQS and not sure how it should work here (need to AWS validate)
  • s3_ObjectCreated_Post -> this is only triggered for pre-signed urls (related test test_create_object_by_presigned_request_via_dynamodb is failing)
  • Only covered notifications that are actually covered by our test suite, but there are more currently not covered, including:
    • s3:ObjectRemoved:DeleteMarkerCreated
    • s3:ObjectRestore:*
    • s3:ReducedRedundancyLostObject
    • s3:Replication:*
    • s3:LifecycleExpiration:*

@steffyP steffyP changed the title S3 notifications migrate S3 notifications to ASF Sep 21, 2022
@steffyP steffyP temporarily deployed to localstack-ext-tests September 22, 2022 18:13 Inactive
@steffyP steffyP temporarily deployed to localstack-ext-tests September 22, 2022 18:16 Inactive
@steffyP steffyP marked this pull request as ready for review September 22, 2022 18:17
@steffyP steffyP removed the request for review from dominikschubert September 22, 2022 18:17
@github-actions
Copy link

github-actions bot commented Sep 22, 2022

LocalStack integration with Pro

0 tests   0 ✔️  0s ⏱️
0 suites  0 💤
0 files    0

Results for commit 4b60a7f.

♻️ This comment has been updated with latest results.

@steffyP steffyP temporarily deployed to localstack-ext-tests September 22, 2022 19:31 Inactive
@coveralls
Copy link

coveralls commented Sep 22, 2022

Coverage Status

Coverage decreased (-0.4%) to 79.532% when pulling 627a713 on s3-notifications into cf8a254 on master.

@steffyP steffyP temporarily deployed to localstack-ext-tests September 23, 2022 07:50 Inactive
@steffyP steffyP temporarily deployed to localstack-ext-tests September 23, 2022 07:59 Inactive
@steffyP steffyP temporarily deployed to localstack-ext-tests September 23, 2022 10:46 Inactive
Comment on lines 105 to 109
class InvalidArgumentError(CommonServiceException):
def __init__(self, message: str, name: str, value: str):
super().__init__("InvalidArgument", message, 400, False)
# TODO how to set values?

Copy link
Member Author

@steffyP steffyP Sep 23, 2022

Choose a reason for hiding this comment

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

@bentsku already added a batch for this exception here. I added a few TODOs where we need to replace this exception, once the related PR is merged.

Copy link
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

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

great progress on the provider!

i have two major points that i think we should address, either in this PR or as part of an immediate refactoring:

  1. processing notifications asynchronously
  2. i think the event notification code would be easier to understand and more maintainable if we used OOP concepts and introduced some basic abstractions. in particular to process event notifications asynchronously it will help to encapsulate the event context into an object, and homogenize the send_event api. i made some suggestions inline.

i think 1. is quite essential since that seems to be how AWS behaves. at least in the lambda documentation it says that Amazon S3 invokes your function asynchronously.

in terms of code organization i think we should move all the code related to notifications into a separate module notifications.py to keep the provider.py a little slimmer.

@bentsku let's discuss who will do the refactoring.

localstack/services/s3/provider.py Outdated Show resolved Hide resolved
localstack/services/s3/provider.py Outdated Show resolved Hide resolved
localstack/services/s3/provider.py Outdated Show resolved Hide resolved
localstack/services/s3/provider.py Outdated Show resolved Hide resolved
localstack/services/s3/provider.py Outdated Show resolved Hide resolved
localstack/services/s3/provider.py Outdated Show resolved Hide resolved
localstack/services/s3/provider.py Outdated Show resolved Hide resolved
localstack/services/s3/provider.py Outdated Show resolved Hide resolved
localstack/services/s3/provider.py Outdated Show resolved Hide resolved
localstack/services/s3/provider.py Outdated Show resolved Hide resolved
@bentsku bentsku temporarily deployed to localstack-ext-tests September 28, 2022 11:20 Inactive
@bentsku bentsku requested a review from thrau September 28, 2022 11:20
Copy link
Member

@thrau thrau left a comment

Choose a reason for hiding this comment

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

this is great! thanks for refactoring this @bentsku , i think this is much cleaner and easier to understand, and also more maintainable!

localstack/services/s3/notifications.py Outdated Show resolved Hide resolved
localstack/services/s3/notifications.py Show resolved Hide resolved
localstack/services/s3/notifications.py Outdated Show resolved Hide resolved
@bentsku bentsku temporarily deployed to localstack-ext-tests September 29, 2022 15:58 Inactive
@bentsku bentsku temporarily deployed to localstack-ext-tests September 30, 2022 14:57 Inactive
@thrau thrau temporarily deployed to localstack-ext-tests September 30, 2022 16:31 Inactive
steffyP and others added 3 commits September 30, 2022 18:43
 - store notification config in s3-store
 - notifications for eventbridge, sqs, sns, lambda
 - add snapshot to tests
 - implement filter validation
 - add verification for notification destination
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.

None yet

4 participants