-
Notifications
You must be signed in to change notification settings - Fork 7
Handle s3:TestEvent (and other unexpected events) #524
base: master
Are you sure you want to change the base?
Conversation
akarve
commented
May 15, 2019
•
edited
Loading
edited
- Make indexer more robust to unexpected event types
- Slight readability tweaks
- Testing
Codecov Report
@@ Coverage Diff @@
## master #524 +/- ##
=======================================
Coverage 86.06% 86.06%
=======================================
Files 25 25
Lines 3395 3395
=======================================
Hits 2922 2922
Misses 473 473 Continue to review full report at Codecov.
|
lambdas/es/indexer/index.py
Outdated
raw_message = json.loads(outer['body'])['Message'] | ||
message = json.loads(raw_message) | ||
if 'Records' not in message: | ||
# consume event (we don't want to index it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure to be the only consumer of the events in this Queue? If not, it might be worth writing a special case for TestEvent and simply ignoring (not consuming) other events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stevededalus is there a way to ignore events without consuming them? from what i read below, consumption == lambda task did not throw.
lambdas/es/indexer/index.py
Outdated
@@ -185,7 +194,8 @@ def handler(event, _): | |||
elif eventname == 'ObjectCreated:Put': | |||
event_type = 'Create' | |||
else: | |||
event_type = eventname | |||
# we should only send either Create or Delete events | |||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Event handling is kind of weird in the indexer before your change, but we need to handle many more event types than what are explicitly mentioned. https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning without handling these events will lead to objects not being indexed correctly