Commit Graph

11 Commits

Author SHA1 Message Date
Rebecca Law
46b72a6bbb Refactor process_ses_receipt
It is possible a service has data rention that is smaller than the time it takes to get a delivery receipt.
This PR refactors process_ses_receipt to update NotificationHistory if the Notifcation has already been purged.
2020-03-27 14:12:39 +00:00
Katie Smith
38243cf860 Stop calling fixtures as functions in the tests 2019-10-30 13:05:53 +00:00
Alexey Bezhan
6f5822ae5b Downgrade log level for missing notifications in SES receipt
The timestamps available in the SES receipt don't always correspond
to the time the notification has been sent. We've seen callbacks with
a current timestamp in both 'mail' and 'bounce' objects that referenced
a notification sent a week ago, which means we can't rely on it to skip
archived notifications.

One possible approach would be to look up the notification reference in
the notification_history table, but this goes against our plans to stop
relying on it in the future.

This changes the SES receipts logic to retry missing notifications once
(if the callback timestamp is within the last 5 minutes the task will
retry after a 5 minute delay) to capture callbacks arriving before the
notification reference has been persisted to the DB. Otherwise, we log
the missing notification as a warning instead of error.
2019-03-06 11:35:32 +00:00
Alexey Bezhan
2932b44eb8 Add retries for SES callbacks for recent notifications
We've seen errors caused by what we suspect is a race condition when
SES callback processing tries to look up the notification before the
sender worker has saved notification reference from the SES POST
response to the database.

This adds a retry for SES callback task if the notification was not
found and the message is less than 10 minutes old and removes the
error log message for notifications older than 3 days (since they
might no longer exist in the notifications table and would've been
marked as failure by then either way).

In order to be able to call retry and silence the error log based on
notification time this change inlines `process_ses_response` and
`update_notification_by_reference` functions into the celery task.
It also removes a lot of defensive error-handling that doesn't appear
to have been triggered in the last few months (for things like missing
keys in SES callback data).
2019-02-25 10:36:37 +00:00
Rebecca Law
56c6d5101c Add some useful information to the log.
Fix unit test to actually test the right thing
2018-06-07 12:30:04 +01:00
Rebecca Law
4966da8289 Fix to handle_complaints.
The json we were getting from SES was not quite as expected, the test data now reflects what we get.
New test added, fix a test that was passing regardless.
2018-06-06 10:37:31 +01:00
Rebecca Law
c5524a3fe9 [WIP] 2018-06-05 17:23:24 +01:00
Rebecca Law
7fa42c2cc5 When SES callback is for a complaint save that to the new complaints table.
When handling the complaint we don't want to throw an exception if the message is missing fields. Only log an exception if we are unable to tie a complaint to a notification.
2018-06-04 17:29:58 +01:00
Rebecca Law
23e6b57c26 Remove email from the log message 2018-05-30 16:45:18 +01:00
Rebecca Law
e82fa2c8d4 Added a way to handle complaint responses from SES.
At this point we are just logging the message so that we can confirm the contents of the SES message.

refer to: https://www.pivotaltracker.com/story/show/157969699
2018-05-30 16:16:36 +01:00
venusbb
489f43a2c9 rename callback_tasks.py to process_ses_receipts.py
create service_callback_tasks.py for tasks to send delivery statuses to services
2017-12-01 16:15:21 +00:00