mitodl / odl-video-service

building blocks for a basic video service for ODL
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

Raise an exception to Sentry when notifications bounce #323

Open pdpinch opened 6 years ago

pdpinch commented 6 years ago

Similar to https://github.com/mitodl/micromasters/issues/3549

If a notification email to a collection owner or admin list bounces, Mailmain will add it to its bounce list and never send to that address again.

I think we want to raise an exception to Sentry when this happens so we can investigate the issue. Does the list need to be updated or removed? What is a temporary issue, and we need to remove the list form Mailgun's bounce list?

adorsk commented 6 years ago

@pdpinch It looks look mailgun does not provide bounce feedback during the request/response exchange that happens when we send an email. Instead, it provides bounce feedback either through a 'bounce' endpoint (pull), or through webhooks (push) .

I can think of a few options for tracking bounces.

1. automated poll

  1. Setup a cron job that polls Mailgun's bounce endpoint every x days.
  2. For each bounce message... a. raise a sentry error for the message. b. clear the message Mailgun's bounce list.
  3. At some later time a human looks through the sentry log.

Pros:

  1. Consolidates bounce errors into sentry log.

Cons:

  1. Still requires human review in sentry.

2. Human Poll

  1. A human looks at Mailgun's bounce endpoint every x days.

Pros:

  1. No code needed!

Cons:

  1. Human has to periodically check. But this is also true for sentry.

3. Automated Push

  1. We add a handler for Mailgun to send webhook events.
  2. When we receive a bounce event, we raise a sentry error.
  3. At some later time a human reviews the sentry log.

Pros:

  1. Consolidates errors into sentry log.

Cons:

  1. Requires adding endpoints just for Mailgun.
  2. We can't control when Mailgun sends events, or how many events it sends.

4. Something Else...

Given that we need human polling in any case, I lean towards #2.

@pdpinch, whaddya think?